Typescript ignore "import types"
This is related to this issue.
Specifying
detectiveOptions: {
ts: {
skipTypeImports: true,
}
}
works only for this kind of code
import type { TypeName } from 'path';
but TS is clever enough to auto-detect types (as they don't generate any output on the JS), so this
import { TypeName } from 'path'; // no "type" keyword
should work the same, when TypeName is a type, an interface, a const enum or anything that doesn't generate anything in memory.
In summary, skipTypeImports should work not when there's a import type, but also based on the nature of the imported property as well when there's a basic import.
I was checking the code of how detective-typescript works, and saw that it only sees one file at a time without knowing what's importing. That makes a bit hard detecting if an export is a type-like declaration or a real object.
My recommendation so far would be to recursively get into what the imported file is exporting and check their types. Keep a cache of AST objects to avoid parsing the same file multiple times...
This "easy" feature requires a somehow complex solution. Any thoughts?