-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Use isolatedModules #7326
Comments
There's one annoying behaviour of console.log("Hello, world!");
So any toy module which doesn't use Ideally, we would wait for another option to make the compiler assume every source is a module and enable that at the same time (microsoft/TypeScript#27535). Maybe this will be the behaviour of |
I really don't want to get into modifying tsc directly. Ultimately it is a valid "problem" with the module specification, that you can't disambiguate scripts and modules. There is a proposal to solve this: https://github.com/tc39/proposal-modules-pragma though it doesn't have a lot of traction and movement. I think realistically it is something that will be encountered rarely with Deno. I suspect we can ignored TS1208 like we do with other diagnostics with no ill effect. If we don't want to ignore it, we should rewrite it to indicate that they might want to use |
That problem isn't applicable to us. The host environment should already be able to provide this information out-of-band. It's just TS not allowing us to supply that.
That would be great (that's along the lines of what I meant to modify). |
Status update: 1.4.0 is going to enable this by default in |
|
@nayeemrmn isn't this diagnostic returned in such case? https://github.com/microsoft/TypeScript/blob/4a3b1957727625720eb48a83ee2dca42c55eda17/src/compiler/diagnosticMessages.json#L2858-L2861 |
@bartlomieju That's only for ambient ones i.e. declared globally with |
Then we should definitely enable that option as well and add a test case. |
Wait, looking at the emits, I think Repro: export const enum a {
b = 1,
c = 2,
};
import { a } from "./temp2.ts";
console.log(a.b);
export var a;
(function (a) {
a[a["b"] = 1] = "b";
a[a["c"] = 2] = "c";
})(a || (a = {}));
;
console.log(a.b);
export {}; I can't find docs about this implication either. Must be a TS bug. |
It doesn't imply |
@kitsonk The behaviour is it does imply |
I know what it does... You are saying |
In version 1.4 Deno adopted; - the tsconfig setting [importsNotUsedAsValues](https://www.typescriptlang.org/tsconfig#importsNotUsedAsValues) - denoland/deno#7413 - the tsconfig setting [isolatedModules](https://www.typescriptlang.org/tsconfig#isolatedModules) when using the deno `--unstable` flag - denoland/deno#7326 ([intended to be enabled by default in 1.5](denoland/deno#7326)) These require the use of; - type only imports for values which are only used as types (`importsNotUsedAsValues`) - type only exports for types which are re-exported (`isolatedModules`)
In version 1.4 Deno adopted; - the tsconfig setting [importsNotUsedAsValues](https://www.typescriptlang.org/tsconfig#importsNotUsedAsValues) - denoland/deno#7413 - the tsconfig setting [isolatedModules](https://www.typescriptlang.org/tsconfig#isolatedModules) when using the deno `--unstable` flag - denoland/deno#7326 ([intended to be enabled by default in 1.5](denoland/deno#7326)) These require the use of; - type only imports for values which are only used as types (`importsNotUsedAsValues`) - type only exports for types which are re-exported (`isolatedModules`)
In version 1.4 Deno adopted; - the tsconfig setting [importsNotUsedAsValues](https://www.typescriptlang.org/tsconfig#importsNotUsedAsValues) - denoland/deno#7413 - the tsconfig setting [isolatedModules](https://www.typescriptlang.org/tsconfig#isolatedModules) when using the deno `--unstable` flag - denoland/deno#7326 ([intended to be enabled by default in 1.5](denoland/deno#7326)) These require the use of; - type only imports for values which are only used as types (`importsNotUsedAsValues`) - type only exports for types which are re-exported (`isolatedModules`)
In version 1.4 Deno adopted; - the tsconfig setting [importsNotUsedAsValues](https://www.typescriptlang.org/tsconfig#importsNotUsedAsValues) - denoland/deno#7413 - the tsconfig setting [isolatedModules](https://www.typescriptlang.org/tsconfig#isolatedModules) when using the deno `--unstable` flag - denoland/deno#7326 ([intended to be enabled by default in 1.5](denoland/deno#7326)) These require the use of; - type only imports for values which are only used as types (`importsNotUsedAsValues`) - type only exports for types which are re-exported (`isolatedModules`) Co-authored-by: Benjamin E. Coe <[email protected]>
This is going to break a lot of code, however its important for sanity when running with
--no-check
(type stripping).I propose we do this in a minor release like 1.5.0. Deno is still very much under development and the semver only applies to the Deno namespace and only without the
--unstable
flag.The text was updated successfully, but these errors were encountered: