typescript – make vscode show error when importing commonjs module incorrectly
I have typescript repo with esm and type=module, so, no commonJS.
I need to import a commonJS package and I did something like:
import { aFunction } from 'someCommonJSPackage';
vscode is not complaining about this, but when I build and generate js from ts, then run the js generated it complains that I should do something like:
import someCommonJSPackage from 'someCommonJSPackage';
const { aFunction } = someCommonJSPackage;
How can I make vscode show the error? Some eslint rule I’m missing? Any tsconfig option I’m missing? My tsconfig file looks like:
{
...,
"compilerOptions": {
"types": ["reflect-metadata", "jest", "node"],
"noImplicitAny": true,
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "ES2021",
"allowJs": true,
"esModuleInterop": true,
"strict": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"lib": ["es6", "es2021", "esnext.asyncIterable"],
}
}
Read more here: Source link