Skip to content

Commit

Permalink
feat(unstable): enable isolatedModules by default (#7327)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacasonato committed Sep 8, 2020
1 parent 241d228 commit 6ff9395
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cli/tsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,8 @@ impl TsCompiler {
"esModuleInterop": true,
"incremental": true,
"inlineSourceMap": true,
// TODO(lucacasonato): enable this by default in 1.5.0
"isolatedModules": unstable,
"jsx": "react",
"lib": lib,
"module": "esnext",
Expand Down Expand Up @@ -1252,6 +1254,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 @@ -878,6 +878,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 @@ -1162,7 +1169,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 @@ -1333,7 +1342,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

0 comments on commit 6ff9395

Please sign in to comment.