diff --git a/deploy/createTypesPackages.js b/deploy/createTypesPackages.js index 6009e92a7..a5ade5990 100644 --- a/deploy/createTypesPackages.js +++ b/deploy/createTypesPackages.js @@ -17,7 +17,7 @@ export const packages = [ readme: "./readmes/web.md", files: [ { from: "../generated/dom.generated.d.ts", to: "index.d.ts" }, - { from: "../generated/dom.iterable.generated.d.ts", to: "index.iterable.d.ts", autoImport: true }, + { from: "../generated/dom.iterable.generated.d.ts", to: "iterable.d.ts", autoImport: true }, ], }, { @@ -26,7 +26,7 @@ export const packages = [ readme: "./readmes/serviceworker.md", files: [ { from: "../generated/serviceworker.generated.d.ts", to: "index.d.ts" }, - { from: "../generated/serviceworker.iterable.generated.d.ts", to: "index.iterable.d.ts", autoImport: true }, + { from: "../generated/serviceworker.iterable.generated.d.ts", to: "iterable.d.ts", autoImport: true }, ], }, { @@ -35,7 +35,7 @@ export const packages = [ readme: "./readmes/audioworklet.md", files: [ { from: "../generated/audioworklet.generated.d.ts", to: "index.d.ts" }, - { from: "../generated/audioworklet.iterable.generated.d.ts", to: "index.iterable.d.ts", autoImport: true }, + { from: "../generated/audioworklet.iterable.generated.d.ts", to: "iterable.d.ts", autoImport: true }, ], }, { @@ -44,7 +44,7 @@ export const packages = [ readme: "./readmes/sharedworker.md", files: [ { from: "../generated/sharedworker.generated.d.ts", to: "index.d.ts" }, - { from: "../generated/sharedworker.iterable.generated.d.ts", to: "index.iterable.d.ts", autoImport: true }, + { from: "../generated/sharedworker.iterable.generated.d.ts", to: "iterable.d.ts", autoImport: true }, ], }, ]; diff --git a/deploy/readmes/audioworklet.md b/deploy/readmes/audioworklet.md index efe92e521..ffacad6dc 100644 --- a/deploy/readmes/audioworklet.md +++ b/deploy/readmes/audioworklet.md @@ -18,6 +18,7 @@ To use `@types/audioworklet` you need to do two things: That's all. +If you'd like to ensure that the DOM types are never accidentally included, you can use [@orta/types-noop]()https://www.npmjs.com/package/@orta/type-noops) in TypeScript 4.5+. ## SemVer diff --git a/deploy/readmes/serviceworker.md b/deploy/readmes/serviceworker.md index a5b85f89c..797d36800 100644 --- a/deploy/readmes/serviceworker.md +++ b/deploy/readmes/serviceworker.md @@ -18,6 +18,7 @@ To use `@types/serviceworker` you need to do two things: That's all. +If you'd like to ensure that the DOM types are never accidentally included, you can use [@orta/types-noop]()https://www.npmjs.com/package/@orta/type-noops) in TypeScript 4.5+. ## SemVer diff --git a/deploy/readmes/sharedworker.md b/deploy/readmes/sharedworker.md index 3ead55c7f..0787efb29 100644 --- a/deploy/readmes/sharedworker.md +++ b/deploy/readmes/sharedworker.md @@ -11,13 +11,14 @@ This package contains type definitions which will set up the global environment To use `@types/sharedworker` you need to do two things: 1. Install the dependency: `npm install @types/sharedworker --save-dev`, `yarn add @types/sharedworker --dev` or `pnpm add @types/sharedworker --dev`. + 1. Update your [`tsconfig.json`](https://www.typescriptlang.org/tsconfig) to avoid clashing with the DOM APIs. There are two cases to consider depending on if you have `lib` defined in your `tsconfig.json` or not. 1. **Without "lib"** - You will need to add `"lib": []`. The value you want to add inside your lib should correlate to your [`"target"`](https://www.typescriptlang.org/tsconfig#target). For example if you had `"target": "es2017"`, then you would add `"lib": ["es2017"]` 1. **With "lib"** - You should remove `"dom"`. -That's all. +If you'd like to ensure that the DOM types are never accidentally included, you can use [@orta/types-noop]()https://www.npmjs.com/package/@orta/type-noops) in TypeScript 4.5+. ## SemVer diff --git a/deploy/readmes/web.md b/deploy/readmes/web.md index b9dfe7715..69414e12a 100644 --- a/deploy/readmes/web.md +++ b/deploy/readmes/web.md @@ -8,6 +8,20 @@ The APIs inside `@types/web` are [generated from](https://github.com/microsoft/T ## Installation +With TypeScript 4.5+ using [lib replacement](https://github.com/microsoft/TypeScript/pull/45771), you can swap the DOM lib with this dependency: + +```sh +pnpm add @typescript/lib-dom@npm:@types/web --save-dev +npm install @typescript/lib-dom@npm:@types/web --save-dev +yarn add @typescript/lib-dom@npm:@types/web --dev +``` + +That's all. + +
+TypeScript 4.4 and below + +
To use `@types/web` you need to do two things: 1. Install the dependency: `npm install @types/web --save-dev`, `yarn add @types/web --dev` or `pnpm add @types/web --dev`. @@ -17,7 +31,10 @@ To use `@types/web` you need to do two things: 1. **Without "lib"** - You will need to add `"lib": []`. The value you want to add inside your lib should correlate to your [`"target"`](https://www.typescriptlang.org/tsconfig#target). For example if you had `"target": "es2017"`, then you would add `"lib": ["es2017"]` 1. **With "lib"** - You should remove `"dom"`. -That's all. +Removing `"dom"` gives @types/web the chance to provide the same set of global declarations. However, It's possible that your dependencies pull in the TypeScript DOM library, in which case you can either try to make that not happen, or use TypeScript 4.5 to systematically replace the library. + +
+ ## SemVer diff --git a/deploy/readmes/webworker.md b/deploy/readmes/webworker.md index 369771c12..4f06268d0 100644 --- a/deploy/readmes/webworker.md +++ b/deploy/readmes/webworker.md @@ -8,16 +8,34 @@ This package contains type definitions which will set up the global environment ## Installation +With TypeScript 4.5+ using [lib replacement](https://github.com/microsoft/TypeScript/pull/45771), you can swap the WebWorker lib with this dependency: + +```sh +pnpm add @typescript/lib-webworker@npm:@types/webworker --save-dev +npm install @typescript/lib-webworker@npm:@types/webworker --save-dev +yarn add @typescript/lib-webworker@npm:@types/webworker --dev +``` + +That's all. + +
+TypeScript 4.4 and below + +
To use `@types/webworker` you need to do two things: -1. Install the dependency: `npm install @types/webworker --save-dev`, `yarn add @types/webworker --dev` or `pnpm add @types/webworker --dev`. -1. Update your [`tsconfig.json`](https://www.typescriptlang.org/tsconfig) to avoid clashing with the DOM APIs. There are two cases to consider depending on if you have `lib` defined in your `tsconfig.json` or not. +1. Install the dependency: `npm install @types/webworker --save-dev`, `yarn add @types/webworker --dev` or `pnpm add @types/webworker --save-dev`. + +1. Update your [`tsconfig.json`](https://www.typescriptlang.org/tsconfig). There are two cases to consider depending on if you have `lib` defined in your `tsconfig.json` or not. 1. **Without "lib"** - You will need to add `"lib": []`. The value you want to add inside your lib should correlate to your [`"target"`](https://www.typescriptlang.org/tsconfig#target). For example if you had `"target": "es2017"`, then you would add `"lib": ["es2017"]` - 1. **With "lib"** - You should remove `"dom"`. + 1. **With "lib"** - You should remove `"webworker"`. -That's all. +Removing `"webworker"` gives @types/webworker the chance to provide the same set of global declarations. However, It's possible that your dependencies pull in the TypeScript Web Worker library, in which case you can either try to make that not happen, or use TypeScript 4.5 to systematically replace the library. + +
+If you'd like to ensure that the DOM types are never accidentally included, you can use [@orta/types-noop]()https://www.npmjs.com/package/@orta/type-noops) in TypeScript 4.5+. ## SemVer