justinwilaby / sax-wasm

The first streamable, fixed memory XML, HTML, and JSX parser for WebAssembly.
MIT License
168 stars 8 forks source link

Unknown type TextDecoder in node.js TS project #35

Closed Avol-V closed 4 years ago

Avol-V commented 4 years ago

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 4 years ago

Thanks for the report @Avol-V ! I'll get this one handled....