Skip to content

Commit a08c543

Browse files
committed
0.4.0
1 parent 9258aaa commit a08c543

13 files changed

Lines changed: 236 additions & 90 deletions

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,7 @@ Reference the type definitions directly in your TypeScript/JavaScript files...
3535
}
3636
```
3737

38-
For [web workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) (including [service workers](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API)), use `new-javascript/worker` as the path. If you use a `tsconfig.json` or `jsconfig.json` configuration file, you have to exclude the worker files there with the `"exclude"` option so that the DOM lib doesn't get included by default. If your worker is a JavaScript and not TypeScript file, you then have to manually re-enable type checking for the file via `// @ts-check`. Also don't forget to exclude the DOM lib with `no-default-lib="true"`. The start of your worker file should look like this:
39-
40-
```javascript
41-
// @ts-check
42-
/// <reference no-default-lib="true" />
43-
/// <reference types="new-javascript/worker" />
44-
```
38+
Since combining [web worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) scripts and scripts running on the main thread in one project [is rather difficult](https://github.com/BenjaminAster/TypeScript-types-for-new-JavaScript/issues/4#issuecomment-1848361769) in TypeScript by default, all worker-exclusive interfaces (e.g. [`FileReaderSync`](https://developer.mozilla.org/en-US/docs/Web/API/FileReaderSync), [`FileSystemSyncAccessHandle`](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemSyncAccessHandle)) are included by default in this package (see [worker.d.ts](./worker.d.ts)). For service worker and shared worker types, see [Better-TypeScript](https://github.com/BenjaminAster/Better-TypeScript).
4539

4640
For [worklets](https://developer.mozilla.org/en-US/docs/Web/API/Worklet), use `new-javascript/worklet/<WORKLET_NAME>` as the path:
4741
- `new-javascript/worklet/audio` for [audio worklets](https://developer.mozilla.org/en-US/docs/Web/API/AudioWorklet)

index.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
/// <reference lib="DOM" />
44
/// <reference lib="DOM.Iterable" />
55

6+
/// <reference path="./worker.d.ts" />
7+
68
/// <reference path="./css-houdini/worklet-animation.d.ts" />
79
/// <reference path="./css-houdini/worklets.d.ts" />
810

@@ -46,6 +48,8 @@
4648
/// <reference path="./whatwg/file-system.d.ts" />
4749
/// <reference path="./whatwg/html.d.ts" />
4850

51+
/// <reference path="./wicg/background-fetch.d.ts" />
52+
/// <reference path="./wicg/background-sync.d.ts" />
4953
/// <reference path="./wicg/cookie-store.d.ts" />
5054
/// <reference path="./wicg/document-picture-in-picture.d.ts" />
5155
/// <reference path="./wicg/element-timing.d.ts" />
@@ -65,6 +69,7 @@
6569
/// <reference path="./wicg/navigation.d.ts" />
6670
/// <reference path="./wicg/netinfo.d.ts" />
6771
/// <reference path="./wicg/pending-beacon.d.ts" />
72+
/// <reference path="./wicg/periodic-background-sync.d.ts" />
6873
/// <reference path="./wicg/permissions-request.d.ts" />
6974
/// <reference path="./wicg/permissions-revoke.d.ts" />
7075
/// <reference path="./wicg/portals.d.ts" />
@@ -77,8 +82,3 @@
7782
/// <reference path="./wicg/urlpattern.d.ts" />
7883
/// <reference path="./wicg/web-app-launch.d.ts" />
7984
/// <reference path="./wicg/window-controls-overlay.d.ts" />
80-
81-
interface Navigator extends NavigatorUA { }
82-
interface Navigator extends NavigatorNetworkInformation { }
83-
interface Navigator extends NavigatorDeviceMemory { }
84-
interface Navigator extends GlobalPrivacyControl { }

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "new-javascript",
3-
"version": "0.3.10",
3+
"version": "0.4.0",
44
"description": "TypeScript type definitions for new JavaScript stuff that isn't yet in TypeScript's standard type definitions",
55
"main": "./index.d.ts",
66
"repository": {

privacycg/global-privacy-control.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
interface GlobalPrivacyControl {
77
globalPrivacyControl: boolean;
88
}
9+
10+
interface Navigator extends GlobalPrivacyControl { }

w3c/device-memory.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
interface NavigatorDeviceMemory {
77
readonly deviceMemory: number;
88
}
9+
10+
interface Navigator extends NavigatorDeviceMemory { }

wicg/background-fetch.d.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
// Specification: https://wicg.github.io/background-fetch/
44
// Repository: https://github.com/WICG/background-fetch/
55

6-
/// <reference no-default-lib="true" />
7-
/// <reference lib="ESNext" />
8-
/// <reference lib="WebWorker" />
9-
/// <reference lib="WebWorker.Iterable" />
10-
6+
/// <reference path="../worker.d.ts" />
117
/// <reference path="../w3c/image-resource.d.ts" />
128

139
interface ServiceWorkerGlobalScope {

wicg/background-sync.d.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
// Specification: https://wicg.github.io/background-sync/spec/
44
// Repository: https://github.com/WICG/background-sync
55

6-
/// <reference no-default-lib="true" />
7-
/// <reference lib="ESNext" />
8-
/// <reference lib="WebWorker" />
9-
/// <reference lib="WebWorker.Iterable" />
6+
/// <reference path="../worker.d.ts" />
107

118
interface ServiceWorkerRegistration {
129
readonly sync: SyncManager;

wicg/cookie-store-worker.d.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

wicg/cookie-store.d.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Specification: https://wicg.github.io/cookie-store/
44
// Repository: https://github.com/WICG/cookie-store
55

6+
/// <reference path="../worker.d.ts" />
7+
68
interface CookieStore extends EventTarget {
79
get(name: string): Promise<CookieListItem | null>;
810
get(options: CookieStoreGetOptions): Promise<CookieListItem | null>;
@@ -95,3 +97,22 @@ interface CookieChangeEventInit extends EventInit {
9597
}
9698

9799
declare var cookieStore: CookieStore;
100+
101+
interface ExtendableCookieChangeEvent extends ExtendableEvent {
102+
readonly changed: ReadonlyArray<CookieListItem>;
103+
readonly deleted: ReadonlyArray<CookieListItem>;
104+
}
105+
106+
declare var ExtendableCookieChangeEvent: {
107+
prototype: ExtendableCookieChangeEvent;
108+
new(type: string, eventInitDict?: CookieChangeEventInit): ExtendableCookieChangeEvent;
109+
}
110+
111+
interface ExtendableCookieChangeEventInit extends ExtendableEventInit {
112+
changed: CookieList;
113+
deleted: CookieList;
114+
}
115+
116+
declare var ExtendableCookieChangeEventInit: {
117+
prototype: ExtendableCookieChangeEventInit;
118+
}

wicg/netinfo.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ interface NavigatorNetworkInformation {
2626
readonly connection: NetworkInformation;
2727
}
2828

29+
interface Navigator extends NavigatorNetworkInformation { }
30+
2931
interface NetworkInformation extends EventTarget {
3032
readonly type: ConnectionType;
3133
readonly effectiveType: EffectiveConnectionType;

0 commit comments

Comments
 (0)