Repository navigation
[service_worker_api] remove fetch API interfaces and add new APIs - #13664
16 commits merged into
Conversation
make `ServiceWorkerGlobalScope` interface compatible with `Window`
|
service_worker_api/index.d.ts to author (@tristancaron). Could you review this PR? Checklist
|
ghost
left a comment
There was a problem hiding this comment.
Might be a good time to add linting. (Add tslint.json with { "extends": "../tslint.json" }.)
| @@ -1,3 +1,5 @@ | |||
| /// <reference path="../whatwg-fetch/index.d.ts" /> | |||
| // TypeScript Version: 2.1 | ||
|
|
||
| // <reference path="../es6-promise/es6-promise.d.ts" /> // REMOVED third "/" so this doesn't fire. Problem with duplicate Promises | ||
| // <reference path="../whatwg-fetch/index.d.ts" /> |
| // Definitions: https://github.com/borisyankov/DefinitelyTyped | ||
| // TypeScript Version: 2.1 | ||
|
|
||
| // <reference path="../es6-promise/es6-promise.d.ts" /> // REMOVED third "/" so this doesn't fire. Problem with duplicate Promises |
There was a problem hiding this comment.
Then Travis will fail with compilation errors :/
There was a problem hiding this comment.
Was referring to the commented-out reference.
| * push notification is received. | ||
| * | ||
| * @param [onpushevent] | ||
| */ |
There was a problem hiding this comment.
Jsdoc still indicates that the parameter is optional. (This is a good reason not to have redundant jsdoc annotations.)
|
@Andy-MS I just added FYI: // tslint:disable-next-line dt-header
// Type definitions for service_worker_api
// Project: https://developer.mozilla.org/fr/docs/Web/API/ServiceWorker_API
...And I'm afraid I couldn't remove the |
|
For the header, I would just write |
|
@Andy-MS done. |
|
Thanks! |
This PR removed the incompatible fetch API interfaces in respect to #12476 and #12582, and added new API interfaces as per Sercive Worker Draft.
@mohsen1 we have no choice but to merge the
ServiceWorkerGlobalScopeinterface intoWindow, since there's no other global scopes. Meanwhile, some interfaces inServiceWorkerGlobalScope, eg.onmessage, are not compatible with those inWindow, I don't know if there are some workarounds other than rewriting them like:Update: I found that
lib.webworker.d.tsis using a/// <reference no-default-lib="true"/>directive to exclude the default lib, however when I tried adding the same directive to this lib, I got tons of type missing errors 😢.masterbranch.tscwithout errors.npm run lint package-nameif atslint.jsonis present.Changing an existing definition:
tslint.jsoncontaining{ "extends": "../tslint.json" }.