Microsoft/TypeScript

Unable to access ServiceWorkerGlobalScope via `self.`

Aperta

#14.877 aperta il 27 mar 2017

 (42 commenti) (63 reazioni) (0 assegnatari)TypeScript (13.395 fork)batch import
BugDomain: lib.d.tsHelp Wanted

Metriche repository

Star
 (108.860 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

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

Guida contributor