-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(unstable): enable isolatedModules by default #7327
feat(unstable): enable isolatedModules by default #7327
Conversation
@nayeemrmn pointed out that this would lead to I think we can hack around this issue by rewriting all TypeScript files that do not contain an import or export with a |
Let's not hack files. Try adding it to ignored diagnostics. |
Annoyingly all errors related to Related question: does this error stop TS from actually checking the file, or is it just a warning (or error) it emits? |
What other error are you seeing that uses this code? I'm looking at:
|
It doesn't prevent type checking. We might have to grep the specific text though so the other isolated module related ones are exposed. We haven't done that before, but we should in this case. |
Actually, it seems matching the code to be TS1208 will be enough - I just got confused because the error message changed 3 times in the last few years, so I thought the code could have different messages. It used to be |
cli/tsc_config.rs
Outdated
@@ -48,6 +48,7 @@ const IGNORED_COMPILER_OPTIONS: [&str; 61] = [ | |||
"inlineSourceMap", | |||
"inlineSources", | |||
"init", | |||
"isolatedModules", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean it can't be turned off? 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I guess this is not strictly required - I guess we can let you disable it. I wouldn't see why though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I guess this is not strictly required - I guess we can let you disable it. I wouldn't see why though.
So people can suppress the breakages that would occur, for the short term at least.
For the long term... I'm not sure what our rule is for this. Do we allow any setting that isn't nonsensical in Deno? Or do we only allow settings justified with a use case? I think it was the former.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A static slice of all the compiler options that should be ignored that either have no effect on the compilation or would cause the emit to not work in Deno.
I guess disabling isolatedModules
could cause the emit not to work if we stop using tsc for emit, and just do stripping via swc. The nice thing about defaulting here is that we can guarantee with some certainty that the swc emit will look like a tsc emit. This would also be useful for bundling.
I guess for this first pass we can remove this from the list so people can suppress breakages, and then once we actually have some code that makes the assumption that all typescript code works with isolatedModules
, we can re-add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rule is "anything that has no impact or would have an undesired impact on the emit." It doesn't have to break the emit.
That being said, introducing it in unstable is to get people to adapt to it, and there is certainly a use case where you want an unstable API but you can resolve all the isolatedModules
fixes. We should add it as an ignored option at some point post 1.5.0, like 1.6.0, IMO, but allow it to be changed up to that point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
How to set isolatedModules to false for deno bundle or |
You can not. Our infrastructure only works with |
This enables the
isolatedModules
tsconfig option by default when using--unstable
. This is a stepping stone towards #7326 in 1.5.0.This does not apply to bundle, because
outFile
andisolatedModules
are not compatible.