I've got a d.ts
file that imports an inexistent variable/interface:
import { inexistentVariable } from './myFile.ts'
import { InexistentInterface } from './myTypes.d.ts'
In both cases, my IDEs (VSCode and WebStorm) do not warn me about this. I can actually make use of it with no warnings given:
interface A {
b: InexistentInterface
}
When I hover b
I get b: any
.
This is my tsconfig:
{
"target": "ES5",
"module": "commonjs",
"lib": [
"esnext.asynciterable",
"ES5",
"ES6",
"dom"
],
"compilerOptions": {
"skipLibCheck": true,
"types": ["reflect-metadata", "jest", "jest-chain", "node"],
"outDir": "dist",
"strict": true,
"strictPropertyInitialization": false,
"esModuleInterop": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"downlevelIteration": true,
"baseUrl": ".",
},
"include": [
"./"
],
"exclude": [
"node_modules"
]
}
Is there any way of getting an error when the imported feature does not exist in the codebase?
I believe this is intended behavior of Typescript to ensure cooperation with JavaScript. It was reported on the Typescript Github page here: Import path not checked when not importing any symbols #20534 and labeled "working as intended".
The example on github is a little different compared to what you posted, but the underlying reason for the behavior seems to be the same.