Unknown type TextDecoder in node.js TS project
Closed this issue · 1 comments
Avol-V commented
Describe the bug
With node.js-only TS project (no "dom" in "lib") can't build.
Type TextDecoder
is from DOM.
To Reproduce
tsconfig.json without dom lib, like this:
{
"compilerOptions": {
"target": "ES2019",
"module": "commonjs",
"lib": [
"es2019",
"es2020.bigint",
"es2020.string",
"es2020.symbol.wellknown"
],
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"allowSyntheticDefaultImports": false,
"esModuleInterop": false,
"noEmitOnError": true,
"newLine": "LF",
"removeComments": true,
"declaration": false,
"sourceMap": false,
"importHelpers": false,
"outDir": "./build",
"rootDir": "./src"
},
"typeAcquisition": {
"include": [
"node"
]
},
"include": [
"./src/**/*.ts",
"./types/**/*.d.ts"
]
}
Can't build project, TypeScript error:
node_modules/sax-wasm/lib/saxWasm.d.ts:77:25 - error TS2304: Cannot find name 'TextDecoder'.
Node.js 12.18.0
TypeScript 3.9.5
@types/node 14.0.13
Workaround — add type like this type TextDecoder = never;
.
justinwilaby commented
Thanks for the report @Avol-V ! I'll get this one handled....