← Back to context

Comment by whilenot-dev

17 hours ago

> A mismatch would mean you would get type errors inside the library code

OP doesn't want the types to be checked, they want the types to be stripped. Type stripping ignores tsconfig.json files and any of its features, see: https://nodejs.org/api/typescript.html#type-stripping

Type stripping cannot ignore tsconfig.

TypeScript has different semantics depending on settings in tsconfig e.g. useDefineForClassFields

  • Type stripping can and does ignore tsconfig.json files, from the provided link:

    > Node.js ignores tsconfig.json files and therefore features that depend on settings within tsconfig.json, such as paths or converting newer JavaScript syntax to older standards, are intentionally unsupported.

    Of course import aliases and such features would break.

Yes, but your TypeScript code has to be checked against the libraries in node_modules, and it is significantly costlier to check against implementation files (the .ts/.mts files) than the produced declaration files (the .d.ts files).

  • Sure, that's all correct, of course a performance hit would be noticeable if thousands of dependencies would need to be checked additionally.

    OP is talking about type stripping nonetheless, and I'd put type stripping into the same ballpark as reading ambient declarations, performance wise.