TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

AbortController.abort is missing in lib.webworker.d.ts

Open Shin-Ogata opened this issue 2 years ago • 4 comments

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.

Shin-Ogata avatar Jun 20 '22 03:06 Shin-Ogata

Discussion about when this was first removed can be found in #49283 and #47507

connorlurring avatar Jul 01 '22 13:07 connorlurring

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?

izderadicka avatar Jul 17 '22 07:07 izderadicka

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

gwynjudd avatar Aug 23 '22 02:08 gwynjudd

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

Tarrowren avatar Oct 18 '22 04:10 Tarrowren

I've confirmed that the latest 4.9.3 fixes this issue. 👍

Shin-Ogata avatar Nov 16 '22 07:11 Shin-Ogata