-
Notifications
You must be signed in to change notification settings - Fork 13k
Open
Labels
Design NotesNotes from our design meetingsNotes from our design meetings
Description
noUncheckedSideEffectImports
by default
- [[Funny aside - presenter wrote
import whoops from "whoops"
as an example in the TypeScript playground expecting an error, but gets none because a package namedwhoops
actually exists on npm and we fetched its types.]] - You can write
import * as blah from "./something-that-doesnt-exist-i-swear.css
, you will get an error. - But if you write
import "./something-that-doesnt-exist-i-swear.css
, you will get no error. - We added
--noUncheckedSideEffectImports
to catch this, but its default isfalse
. - For users who want it on but for certain things to work (e.g. importing
.css
files), they either needdeclare module "*.css"
at the top level of (a non-module).d.ts
file.- write a
.d.css.ts
file per CSS file.
- Users can also always
// @ts-ignore
. - If we want it for 6.0, do this immediately on 7.0.
- The reason we didn't add the error initially was because we didn't have pattern ambient modules like
*.filetype
. - Would like to special-case the error message.
- Pattern ambient modules are the least safe way to declare this, which is unfortunate. Sort of defeats the purpose.
Enable --allowImportingTsExtensions
by default
- Most server-side runtimes + bundlers support
.ts
imports. - Want people to just be able to run
.ts
files with no extra flag/ --allowImportingTsExtensions
is off by default.- Requires
--noEmit
though.
- Requires
- There's also
--rewriteRelativeImportExtensions
which is off by default, but wouldn't you actually want this more? - So much of this really needs to be informed by whether you have
--noEmit
. - We don't want to make this behavior dependent on more flags.
- Maybe a good first step is to turn
allowImportingTsExtensions
on in the default editor config. rewriteRelativeImportExtensions
being on depending onoutDir
seems tempting.- "no it isn't!"
- A lot of this is really dependent on the target system.
- This kind of relies on if you're an app author or library author?
- App authors don't care, will likely always run directly from source.
- Library authors care because they must emit; they can't ship
.ts
files.- But can't make
rewriteRelativeImportExtensions
on by default because no defaultoutDir
. - Wait, that's not a problem. That's why
allowJs
must be off by default.
- But can't make
esnext
is a weird target for this.nodenext
?bundler
?- Makes sense under these.
- We should be able to make things "just work" to run
.ts
files in an editor.- Sure, but what happens as soon as you add a
tsconfig.json
?
- Sure, but what happens as soon as you add a
- We can fix this in the editor - what about type-checking?
petamoriken and ExE-Boss
Metadata
Metadata
Assignees
Labels
Design NotesNotes from our design meetingsNotes from our design meetings