Microsoft/TypeScript

Unable to access ServiceWorkerGlobalScope via `self.`

Open

#14,877 创建于 2017年3月27日

在 GitHub 查看
 (42 评论) (63 反应) (0 负责人)TypeScript (48,455 star) (6,726 fork)batch import
BugDomain: lib.d.tsHelp Wanted

描述

Since ServiceWorker related types sit in lib.webworker.d.ts, webworker lib need to be added to tsconfig.json.

{
  "compilerOptions": {
    "lib": [
      "es2017",
      "webworker"
    ]
  }
}

But in current lib.webworker.d.ts, it declare var self: WorkerGlobalScope;, so we can't access ServiceWorkerGlobalScope via self.


TypeScript Version: 2.2.1

Expected behavior:

Can access ServiceWorkerGlobalScope via self.(like self.clients)

Actual behavior:

Access with error.

image

贡献者指南

Unable to access ServiceWorkerGlobalScope via `self.` · Microsoft/TypeScript#14877 | Good First Issue