Skip to content
Open
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
3 changes: 3 additions & 0 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,9 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [
{
name: "isolatedModules",
type: "boolean",
affectsSemanticDiagnostics: true,
affectsEmit: true,
affectsBuildInfo: true,
category: Diagnostics.Interop_Constraints,
description: Diagnostics.Ensure_that_each_file_can_be_safely_transpiled_without_relying_on_other_imports,
transpileOptionValue: true,
Expand Down
47 changes: 47 additions & 0 deletions src/testRunner/unittests/tscWatch/programUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2488,4 +2488,51 @@ import { x } from "../b";`,
},
],
});

verifyTscWatch({
scenario,
subScenario: "toggling isolatedModules re-emits const enums",
commandLineArgs: ["-w"],
sys: () => {
const enumFile: File = {
path: `/user/username/projects/myproject/a.ts`,
content: `const enum TestEnum { a = 1, b = 3, c = 5 }
const x = TestEnum.b;`,
};
const configFile: File = {
path: `/user/username/projects/myproject/tsconfig.json`,
content: jsonToReadableText({
compilerOptions: {},
}),
};
return TestServerHost.createWatchedSystem(
[enumFile, configFile],
{ currentDirectory: "/user/username/projects/myproject" },
);
},
edits: [
{
caption: "Enable isolatedModules — const enum should no longer be inlined",
edit: sys =>
sys.writeFile(
`/user/username/projects/myproject/tsconfig.json`,
jsonToReadableText({
compilerOptions: { isolatedModules: true },
}),
),
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
},
{
caption: "Disable isolatedModules — const enum should be inlined again",
edit: sys =>
sys.writeFile(
`/user/username/projects/myproject/tsconfig.json`,
jsonToReadableText({
compilerOptions: { isolatedModules: false },
}),
),
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
},
],
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
currentDirectory:: /user/username/projects/myproject useCaseSensitiveFileNames:: false
Input::
//// [/user/username/projects/myproject/a.ts]
const enum TestEnum { a = 1, b = 3, c = 5 }
const x = TestEnum.b;

//// [/user/username/projects/myproject/tsconfig.json]
{
"compilerOptions": {}
}

//// [/home/src/tslibs/TS/Lib/lib.d.ts]
interface Boolean {}
interface Function {}
interface CallableFunction {}
interface NewableFunction {}
interface IArguments {}
interface Number { toExponential: any; }
interface Object {}
interface RegExp {}
interface String { charAt: any; }
interface Array<T> { length: number; [n: number]: T; }
interface ReadonlyArray<T> {}
declare const console: { log(msg: any): void; };


/home/src/tslibs/TS/Lib/tsc.js -w
Output::
>> Screen clear
[HH:MM:SS AM] Starting compilation in watch mode...

[HH:MM:SS AM] Found 0 errors. Watching for file changes.



//// [/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts] *Lib*

//// [/user/username/projects/myproject/a.js]
"use strict";
const x = 3 /* TestEnum.b */;



FsWatches::
/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts: *new*
{}
/user/username/projects/myproject/a.ts: *new*
{}
/user/username/projects/myproject/tsconfig.json: *new*
{}

FsWatchesRecursive::
/user/username/projects/myproject: *new*
{}

Program root files: [
"/user/username/projects/myproject/a.ts"
]
Program options: {
"watch": true,
"configFilePath": "/user/username/projects/myproject/tsconfig.json"
}
Program structureReused: Not
Program files::
/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts
/user/username/projects/myproject/a.ts

Semantic diagnostics in builder refreshed for::
/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts
/user/username/projects/myproject/a.ts

Shape signatures in builder refreshed for::
/home/src/tslibs/ts/lib/lib.es2025.full.d.ts (used version)
/user/username/projects/myproject/a.ts (used version)

exitCode:: ExitStatus.undefined

Change:: Enable isolatedModules — const enum should no longer be inlined

Input::
//// [/user/username/projects/myproject/tsconfig.json]
{
"compilerOptions": {
"isolatedModules": true
}
}


Timeout callback:: count: 1
1: timerToUpdateProgram *new*

Before running Timeout callback:: count: 1
1: timerToUpdateProgram

Host is moving to new time
After running Timeout callback:: count: 0
Output::
>> Screen clear
[HH:MM:SS AM] File change detected. Starting incremental compilation...

[HH:MM:SS AM] Found 0 errors. Watching for file changes.



//// [/user/username/projects/myproject/a.js]
"use strict";
var TestEnum;
(function (TestEnum) {
TestEnum[TestEnum["a"] = 1] = "a";
TestEnum[TestEnum["b"] = 3] = "b";
TestEnum[TestEnum["c"] = 5] = "c";
})(TestEnum || (TestEnum = {}));
const x = TestEnum.b;




Program root files: [
"/user/username/projects/myproject/a.ts"
]
Program options: {
"isolatedModules": true,
"watch": true,
"configFilePath": "/user/username/projects/myproject/tsconfig.json"
}
Program structureReused: Completely
Program files::
/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts
/user/username/projects/myproject/a.ts

Semantic diagnostics in builder refreshed for::
/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts
/user/username/projects/myproject/a.ts

No shapes updated in the builder::

exitCode:: ExitStatus.undefined

Change:: Disable isolatedModules — const enum should be inlined again

Input::
//// [/user/username/projects/myproject/tsconfig.json]
{
"compilerOptions": {
"isolatedModules": false
}
}


Timeout callback:: count: 1
2: timerToUpdateProgram *new*

Before running Timeout callback:: count: 1
2: timerToUpdateProgram

Host is moving to new time
After running Timeout callback:: count: 0
Output::
>> Screen clear
[HH:MM:SS AM] File change detected. Starting incremental compilation...

[HH:MM:SS AM] Found 0 errors. Watching for file changes.



//// [/user/username/projects/myproject/a.js]
"use strict";
const x = 3 /* TestEnum.b */;




Program root files: [
"/user/username/projects/myproject/a.ts"
]
Program options: {
"isolatedModules": false,
"watch": true,
"configFilePath": "/user/username/projects/myproject/tsconfig.json"
}
Program structureReused: Completely
Program files::
/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts
/user/username/projects/myproject/a.ts

Semantic diagnostics in builder refreshed for::
/home/src/tslibs/TS/Lib/lib.es2025.full.d.ts
/user/username/projects/myproject/a.ts

No shapes updated in the builder::

exitCode:: ExitStatus.undefined