TypeScript
TypeScript copied to clipboard
AbortController.abort is missing in lib.webworker.d.ts
Bug Report
AbortController.abort
remains commented out and is not available in lib.webworker.d.ts.
🔎 Search Terms
AbortController, abort
🕗 Version & Regression Information
It's from v4.7.2
. It was OK in v4.6.4
.
And also, lib.dom.d.ts is fine.
💻 Code
const controller = new AbortController();
const cancel = (): void => controller.abort();
🙁 Actual behavior
src/core.ts:99:42 - error TS2339: Property 'abort' does not exist on type 'AbortController'.
99 const cancel = (): void => controller.abort();
~~~~~
🙂 Expected behavior
The correct behavior is that even in a worker can compile correctly.
Discussion about when this was first removed can be found in #49283 and #47507
It impacts me on service worker project where "lib": ["es6", "WebWorker"],
only in tsconfig and compiling with tsc gives the error. Strangely VS Code is OK, probably because it has correct definition from DOM types?
Sorry, but is anything going to be done about this? It does seem a bit like throwing the baby out with the bathwater to just remove it. It is a bit impactful to leave it like this. Just looking for some clarification on the plans, since this issue is still in open status
this is my project configuration:
// node/tsconfig.json
{
"compilerOptions": {
"module": "CommonJS",
"moduleResolution": "Node",
"target": "ES2020",
"lib": ["ES2020"],
"rootDir": "src",
"outDir": "out",
"strict": true,
"esModuleInterop": true,
"sourceMap": true
},
"include": ["**/*.ts"]
}
// browser/tsconfig.json
{
"compilerOptions": {
"module": "ES2020",
"moduleResolution": "Node",
"target": "ES2020",
"lib": ["ES2020", "WebWorker"],
"rootDir": "src",
"outDir": "out",
"types": [],
"strict": true,
"esModuleInterop": true,
"sourceMap": true
},
"include": ["**/*.ts"]
}
you can set types
to []
to exclude @types/node,
so there is no need to remove AbortController.abort
from lib.webworker.d.ts
I've confirmed that the latest 4.9.3 fixes this issue. 👍