When working with Visual Studio Code and importing two JavaScript module files, such as A.js and B.js, into another file called C.ts, autocomplete may not work properly. Despite suggestions to create declaration files for module A, I prefer to avoid this because VS Code should already recognize declarations when importing JS modules into other JS files. The environment is Node.js.
For instance:
// A.js
export const some_variable = 1
// B.js
import * as A from 'A.js'
A.some_variable --> offers autocomplete and suggestions
// C.ts
import * as A from 'A.js' --> displays a warning and lacks autocomplete support for A.
A.some_variable --> does not trigger an error but autocomplete is missing
Is there a method to import JS modules into TS files without using declaration files in order to enable autocomplete and type checking?
EDIT: (tsconfig.json)
{
"compilerOptions": {
"baseUrl": ".",
"esModuleInterop": true,
"lib": ["es2015"],
"module": "commonjs",
"noImplicitAny": false,
"outDir": ".build",
"paths": {
"*": ["node_modules/*"]
},
"preserveConstEnums": true,
"resolveJsonModule": true,
"rootDir": "",
"sourceMap": true,
"strictNullChecks": true,
"target": "es6",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noImplicitUseStrict": true,
"checkJs": true,
"allowSyntheticDefaultImports": true,
"declaration": true,
"allowJs": true
}
}