Skip to content
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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cli/tsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,8 @@ impl TsCompiler {
"esModuleInterop": true,
"incremental": true,
"inlineSourceMap": true,
// TODO(lucacasonato): enable this by default in 1.5.0
"isolatedModules": unstable,
lucacasonato marked this conversation as resolved.
Show resolved Hide resolved
"jsx": "react",
"lib": lib,
"module": "esnext",
Expand Down Expand Up @@ -1248,6 +1250,8 @@ pub async fn runtime_compile(
"allowNonTsExtensions": true,
"checkJs": false,
"esModuleInterop": true,
// TODO(lucacasonato): enable this by default in 1.5.0
"isolatedModules": unstable,
"jsx": "react",
"module": "esnext",
"sourceMap": true,
Expand Down
16 changes: 14 additions & 2 deletions cli/tsc/99_main_compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,13 @@ delete Object.prototype.__proto__;
7016,
];

const IGNORED_COMPILE_DIAGNOSTICS = [
// TS1208: All files must be modules when the '--isolatedModules' flag is
// provided. We can ignore because we guarantuee that all files are
// modules.
1208,
];

const stats = [];
let statsStart = 0;

Expand Down Expand Up @@ -1163,7 +1170,9 @@ delete Object.prototype.__proto__;
...program.getSemanticDiagnostics(),
];
diagnostics = diagnostics.filter(
({ code }) => !IGNORED_DIAGNOSTICS.includes(code),
({ code }) =>
!IGNORED_DIAGNOSTICS.includes(code) &&
!IGNORED_COMPILE_DIAGNOSTICS.includes(code),
);

// We will only proceed with the emit if there are no diagnostics.
Expand Down Expand Up @@ -1334,7 +1343,10 @@ delete Object.prototype.__proto__;

const diagnostics = ts
.getPreEmitDiagnostics(program)
.filter(({ code }) => !IGNORED_DIAGNOSTICS.includes(code));
.filter(({ code }) =>
!IGNORED_DIAGNOSTICS.includes(code) &&
!IGNORED_COMPILE_DIAGNOSTICS.includes(code)
);

const emitResult = program.emit();
assert(emitResult.emitSkipped === false, "Unexpected skip of the emit.");
Expand Down