diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts
index 70bd2c29b7a..ba62eb16d39 100644
--- a/src/compiler/commandLineParser.ts
+++ b/src/compiler/commandLineParser.ts
@@ -968,6 +968,7 @@ namespace ts {
name: "useDefineForClassFields",
type: "boolean",
affectsSemanticDiagnostics: true,
+ affectsEmit: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Emit_class_fields_with_Define_instead_of_Set,
},
diff --git a/src/testRunner/unittests/tscWatch/programUpdates.ts b/src/testRunner/unittests/tscWatch/programUpdates.ts
index ede0927aa19..82d61ae2557 100644
--- a/src/testRunner/unittests/tscWatch/programUpdates.ts
+++ b/src/testRunner/unittests/tscWatch/programUpdates.ts
@@ -1121,6 +1121,31 @@ foo().hello`
]
});
+ verifyTscWatch({
+ scenario,
+ subScenario: "updates diagnostics and emit when useDefineForClassFields changes",
+ commandLineArgs: ["-w"],
+ sys: () => {
+ const aFile: File = {
+ path: `/a.ts`,
+ content: `class C { get prop() { return 1; } }
+class D extends C { prop = 1; }`
+ };
+ const config: File = {
+ path: `/tsconfig.json`,
+ content: JSON.stringify({ compilerOptions: { target: "es6" } })
+ };
+ return createWatchedSystem([aFile, config, libFile]);
+ },
+ changes: [
+ sys => {
+ sys.writeFile(`/tsconfig.json`, JSON.stringify({ compilerOptions: { target: "es6", useDefineForClassFields: true } }));
+ sys.runQueuedTimeoutCallbacks();
+ return "Enable useDefineForClassFields";
+ },
+ ]
+ });
+
verifyTscWatch({
scenario,
subScenario: "updates errors and emit when importsNotUsedAsValues changes",
diff --git a/tests/baselines/reference/tscWatch/programUpdates/updates-diagnostics-and-emit-when-useDefineForClassFields-changes.js b/tests/baselines/reference/tscWatch/programUpdates/updates-diagnostics-and-emit-when-useDefineForClassFields-changes.js
new file mode 100644
index 00000000000..f5c4d978b17
--- /dev/null
+++ b/tests/baselines/reference/tscWatch/programUpdates/updates-diagnostics-and-emit-when-useDefineForClassFields-changes.js
@@ -0,0 +1,128 @@
+/a/lib/tsc.js -w
+//// [/a.ts]
+class C { get prop() { return 1; } }
+class D extends C { prop = 1; }
+
+//// [/tsconfig.json]
+{"compilerOptions":{"target":"es6"}}
+
+//// [/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; }
+
+//// [/a.js]
+class C {
+ get prop() { return 1; }
+}
+class D extends C {
+ constructor() {
+ super(...arguments);
+ this.prop = 1;
+ }
+}
+
+
+
+Output::
+>> Screen clear
+12:00:13 AM - Starting compilation in watch mode...
+
+
+
+12:00:16 AM - Found 0 errors. Watching for file changes.
+
+
+Program root files: ["/a.ts","/a/lib/lib.d.ts"]
+Program options: {"target":2,"watch":true,"configFilePath":"/tsconfig.json"}
+Program files::
+/a.ts
+/a/lib/lib.d.ts
+
+Semantic diagnostics in builder refreshed for::
+/a.ts
+/a/lib/lib.d.ts
+
+WatchedFiles::
+/tsconfig.json:
+ {"pollingInterval":250}
+/a.ts:
+ {"pollingInterval":250}
+/a/lib/lib.d.ts:
+ {"pollingInterval":250}
+
+FsWatches::
+
+FsWatchesRecursive::
+/:
+ {"fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+
+exitCode:: ExitStatus.undefined
+
+Change:: Enable useDefineForClassFields
+
+//// [/tsconfig.json]
+{"compilerOptions":{"target":"es6","useDefineForClassFields":true}}
+
+//// [/a.js]
+class C {
+ get prop() { return 1; }
+}
+class D extends C {
+ constructor() {
+ super(...arguments);
+ Object.defineProperty(this, "prop", {
+ enumerable: true,
+ configurable: true,
+ writable: true,
+ value: 1
+ });
+ }
+}
+
+
+
+Output::
+>> Screen clear
+12:00:20 AM - File change detected. Starting incremental compilation...
+
+
+a.ts(2,21): error TS2610: 'prop' is defined as an accessor in class 'C', but is overridden here in 'D' as an instance property.
+
+
+12:00:24 AM - Found 1 error. Watching for file changes.
+
+
+Program root files: ["/a.ts","/a/lib/lib.d.ts"]
+Program options: {"target":2,"useDefineForClassFields":true,"watch":true,"configFilePath":"/tsconfig.json"}
+Program files::
+/a.ts
+/a/lib/lib.d.ts
+
+Semantic diagnostics in builder refreshed for::
+/a.ts
+/a/lib/lib.d.ts
+
+WatchedFiles::
+/tsconfig.json:
+ {"pollingInterval":250}
+/a.ts:
+ {"pollingInterval":250}
+/a/lib/lib.d.ts:
+ {"pollingInterval":250}
+
+FsWatches::
+
+FsWatchesRecursive::
+/:
+ {"fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
+
+exitCode:: ExitStatus.undefined