Description
There's a few other issues that touch on something similar (#5098, #278), but is there a way to explicitly import only type information from an external module? I imagine something like below, where there's a reserved word used to modify an existing import:
import type * as ts from 'typescript'
import type ts = require('typescript')
ts.parseJsonConfigFileContent(...) // Error, type information only.
var TS: ts = require('typescript')
ts.parseJsonConfigFileContent(...) // Works great.
This construct would import type information only, and any runtime usage of the namespace in the current module could be considered an error. This is useful in a few place (E.g. ts-node
and tsconfig
) where I need the type information from TypeScript, but I also need to guarantee that I don't accidentally import it as a dependency in the compiled output. Not sure if others have a similar use-case, but the reverse at least seems to be an issue (importing for side-effects only, which is optimized out by the compiler currently).