diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts
index 300e403b371..70bd2c29b7a 100644
--- a/src/compiler/commandLineParser.ts
+++ b/src/compiler/commandLineParser.ts
@@ -480,6 +480,7 @@ namespace ts {
error: importsNotUsedAsValues.Error
}),
affectsEmit: true,
+ affectsSemanticDiagnostics: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types
},
diff --git a/src/testRunner/unittests/tscWatch/programUpdates.ts b/src/testRunner/unittests/tscWatch/programUpdates.ts
index a8539eff38b..ede0927aa19 100644
--- a/src/testRunner/unittests/tscWatch/programUpdates.ts
+++ b/src/testRunner/unittests/tscWatch/programUpdates.ts
@@ -1121,6 +1121,45 @@ foo().hello`
]
});
+ verifyTscWatch({
+ scenario,
+ subScenario: "updates errors and emit when importsNotUsedAsValues changes",
+ commandLineArgs: ["-w"],
+ sys: () => {
+ const aFile: File = {
+ path: `${projectRoot}/a.ts`,
+ content: `export class C {}`
+ };
+ const bFile: File = {
+ path: `${projectRoot}/b.ts`,
+ content: `import {C} from './a';
+export function f(p: C) { return p; }`
+ };
+ const config: File = {
+ path: `${projectRoot}/tsconfig.json`,
+ content: JSON.stringify({ compilerOptions: {} })
+ };
+ return createWatchedSystem([aFile, bFile, config, libFile], { currentDirectory: projectRoot });
+ },
+ changes: [
+ sys => {
+ sys.writeFile(`${projectRoot}/tsconfig.json`, JSON.stringify({ compilerOptions: { importsNotUsedAsValues: "remove" } }));
+ sys.runQueuedTimeoutCallbacks();
+ return 'Set to "remove"';
+ },
+ sys => {
+ sys.writeFile(`${projectRoot}/tsconfig.json`, JSON.stringify({ compilerOptions: { importsNotUsedAsValues: "error" } }));
+ sys.runQueuedTimeoutCallbacks();
+ return 'Set to "error"';
+ },
+ sys => {
+ sys.writeFile(`${projectRoot}/tsconfig.json`, JSON.stringify({ compilerOptions: { importsNotUsedAsValues: "preserve" } }));
+ sys.runQueuedTimeoutCallbacks();
+ return 'Set to "preserve"';
+ },
+ ]
+ });
+
verifyTscWatch({
scenario,
subScenario: "updates errors when ambient modules of program changes",
diff --git a/tests/baselines/reference/tscWatch/programUpdates/updates-errors-and-emit-when-importsNotUsedAsValues-changes.js b/tests/baselines/reference/tscWatch/programUpdates/updates-errors-and-emit-when-importsNotUsedAsValues-changes.js
new file mode 100644
index 00000000000..f4d689a0a5b
--- /dev/null
+++ b/tests/baselines/reference/tscWatch/programUpdates/updates-errors-and-emit-when-importsNotUsedAsValues-changes.js
@@ -0,0 +1,239 @@
+/a/lib/tsc.js -w
+//// [/user/username/projects/myproject/a.ts]
+export class C {}
+
+//// [/user/username/projects/myproject/b.ts]
+import {C} from './a';
+export function f(p: C) { return p; }
+
+//// [/user/username/projects/myproject/tsconfig.json]
+{"compilerOptions":{}}
+
+//// [/a/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 { length: number; [n: number]: T; }
+
+//// [/user/username/projects/myproject/a.js]
+"use strict";
+exports.__esModule = true;
+var C = /** @class */ (function () {
+ function C() {
+ }
+ return C;
+}());
+exports.C = C;
+
+
+//// [/user/username/projects/myproject/b.js]
+"use strict";
+exports.__esModule = true;
+function f(p) { return p; }
+exports.f = f;
+
+
+
+Output::
+>> Screen clear
+12:00:23 AM - Starting compilation in watch mode...
+
+
+
+12:00:28 AM - Found 0 errors. Watching for file changes.
+
+
+Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"]
+Program options: {"watch":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
+Program files::
+/a/lib/lib.d.ts
+/user/username/projects/myproject/a.ts
+/user/username/projects/myproject/b.ts
+
+Semantic diagnostics in builder refreshed for::
+/a/lib/lib.d.ts
+/user/username/projects/myproject/a.ts
+/user/username/projects/myproject/b.ts
+
+WatchedFiles::
+/user/username/projects/myproject/tsconfig.json:
+ {"pollingInterval":250}
+/user/username/projects/myproject/a.ts:
+ {"pollingInterval":250}
+/user/username/projects/myproject/b.ts:
+ {"pollingInterval":250}
+/a/lib/lib.d.ts:
+ {"pollingInterval":250}
+
+FsWatches::
+
+FsWatchesRecursive::
+/user/username/projects/myproject/node_modules/@types:
+ {"fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+/user/username/projects/myproject:
+ {"fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+
+exitCode:: ExitStatus.undefined
+
+Change:: Set to "remove"
+
+//// [/user/username/projects/myproject/tsconfig.json]
+{"compilerOptions":{"importsNotUsedAsValues":"remove"}}
+
+//// [/user/username/projects/myproject/a.js] file written with same contents
+//// [/user/username/projects/myproject/b.js] file written with same contents
+
+Output::
+>> Screen clear
+12:00:32 AM - File change detected. Starting incremental compilation...
+
+
+
+12:00:39 AM - Found 0 errors. Watching for file changes.
+
+
+Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"]
+Program options: {"importsNotUsedAsValues":0,"watch":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
+Program files::
+/a/lib/lib.d.ts
+/user/username/projects/myproject/a.ts
+/user/username/projects/myproject/b.ts
+
+Semantic diagnostics in builder refreshed for::
+/a/lib/lib.d.ts
+/user/username/projects/myproject/a.ts
+/user/username/projects/myproject/b.ts
+
+WatchedFiles::
+/user/username/projects/myproject/tsconfig.json:
+ {"pollingInterval":250}
+/user/username/projects/myproject/a.ts:
+ {"pollingInterval":250}
+/user/username/projects/myproject/b.ts:
+ {"pollingInterval":250}
+/a/lib/lib.d.ts:
+ {"pollingInterval":250}
+
+FsWatches::
+
+FsWatchesRecursive::
+/user/username/projects/myproject/node_modules/@types:
+ {"fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+/user/username/projects/myproject:
+ {"fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+
+exitCode:: ExitStatus.undefined
+
+Change:: Set to "error"
+
+//// [/user/username/projects/myproject/tsconfig.json]
+{"compilerOptions":{"importsNotUsedAsValues":"error"}}
+
+//// [/user/username/projects/myproject/a.js] file written with same contents
+//// [/user/username/projects/myproject/b.js]
+"use strict";
+exports.__esModule = true;
+require("./a");
+function f(p) { return p; }
+exports.f = f;
+
+
+
+Output::
+>> Screen clear
+12:00:43 AM - File change detected. Starting incremental compilation...
+
+
+b.ts(1,1): error TS1371: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
+
+
+12:00:50 AM - Found 1 error. Watching for file changes.
+
+
+Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"]
+Program options: {"importsNotUsedAsValues":2,"watch":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
+Program files::
+/a/lib/lib.d.ts
+/user/username/projects/myproject/a.ts
+/user/username/projects/myproject/b.ts
+
+Semantic diagnostics in builder refreshed for::
+/a/lib/lib.d.ts
+/user/username/projects/myproject/a.ts
+/user/username/projects/myproject/b.ts
+
+WatchedFiles::
+/user/username/projects/myproject/tsconfig.json:
+ {"pollingInterval":250}
+/user/username/projects/myproject/a.ts:
+ {"pollingInterval":250}
+/user/username/projects/myproject/b.ts:
+ {"pollingInterval":250}
+/a/lib/lib.d.ts:
+ {"pollingInterval":250}
+
+FsWatches::
+
+FsWatchesRecursive::
+/user/username/projects/myproject/node_modules/@types:
+ {"fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+/user/username/projects/myproject:
+ {"fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+
+exitCode:: ExitStatus.undefined
+
+Change:: Set to "preserve"
+
+//// [/user/username/projects/myproject/tsconfig.json]
+{"compilerOptions":{"importsNotUsedAsValues":"preserve"}}
+
+//// [/user/username/projects/myproject/a.js] file written with same contents
+//// [/user/username/projects/myproject/b.js] file written with same contents
+
+Output::
+>> Screen clear
+12:00:54 AM - File change detected. Starting incremental compilation...
+
+
+
+12:01:01 AM - Found 0 errors. Watching for file changes.
+
+
+Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"]
+Program options: {"importsNotUsedAsValues":1,"watch":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
+Program files::
+/a/lib/lib.d.ts
+/user/username/projects/myproject/a.ts
+/user/username/projects/myproject/b.ts
+
+Semantic diagnostics in builder refreshed for::
+/a/lib/lib.d.ts
+/user/username/projects/myproject/a.ts
+/user/username/projects/myproject/b.ts
+
+WatchedFiles::
+/user/username/projects/myproject/tsconfig.json:
+ {"pollingInterval":250}
+/user/username/projects/myproject/a.ts:
+ {"pollingInterval":250}
+/user/username/projects/myproject/b.ts:
+ {"pollingInterval":250}
+/a/lib/lib.d.ts:
+ {"pollingInterval":250}
+
+FsWatches::
+
+FsWatchesRecursive::
+/user/username/projects/myproject/node_modules/@types:
+ {"fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+/user/username/projects/myproject:
+ {"fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+
+exitCode:: ExitStatus.undefined