You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The addition of import type and export type really needs a companion flag that errors when using regular import or export with an interface or type. Something to automate the conversion process and provide enforcement.
importsNotUsedAsValues: preserve-exact
#44137
People expect
import fs from "fs"
to compile toimport fs from "fs"
inimportsNotUsedAsValues: preserve
Came up offhandedly.
In places like Svelte, they
eval
some stuff, do a bunch of hacks to ensure that the imports stick around.The idea: new flag.
importsNotUsedAsValues: error
.The PR stops short of some of the work from last time.
type
modifiers on imports.Would erase away those named imports.
How does that play with when you have a default?
type: fs
Requires
es2015
+ as a module target.How does tooling work with this?
This rule applies to both imports and exports
Getting a read for how these options interact is hard.
--isolatedModules
Meaningful use case:
import
means valueimport
,import type
means erased import.But how do you deal with
export { A }
?export type { A }
?Okay, harder case:
Okay, but one is local, we know exactly what it'll be.
Not consistent with "leave my imports and exports alone".
We seem to feel that a local
export {}
is exempt from elision rules because the constructs are all local.If TypeScript was a greenfield project, this is probably what our default would be.
import
vsimport type
is very annoying.Not super big on giving an error in ES5.
Need to think through this a bit more, come up with a coherent write-up.
The text was updated successfully, but these errors were encountered: