diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index beb601b0b8f..04834a11a29 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -380,6 +380,7 @@ namespace ts { name: "jsx", type: jsxOptionMap, affectsSourceFile: true, + affectsEmit: true, paramType: Diagnostics.KIND, showInSimplifiedHelpView: true, category: Diagnostics.Basic_Options, diff --git a/src/testRunner/unittests/tscWatch/programUpdates.ts b/src/testRunner/unittests/tscWatch/programUpdates.ts index 3faa145fe2c..805f9f955b4 100644 --- a/src/testRunner/unittests/tscWatch/programUpdates.ts +++ b/src/testRunner/unittests/tscWatch/programUpdates.ts @@ -1598,5 +1598,33 @@ import { x } from "../b";`), }, ] }); + + verifyTscWatch({ + scenario, + subScenario: "updates emit on jsx option change", + commandLineArgs: ["-w"], + sys: () => { + const index: File = { + path: `${projectRoot}/index.tsx`, + content: `declare var React: any;\nconst d =
;` + }; + const configFile: File = { + path: `${projectRoot}/tsconfig.json`, + content: JSON.stringify({ + compilerOptions: { + jsx: "preserve" + } + }) + }; + return createWatchedSystem([index, configFile, libFile], { currentDirectory: projectRoot }); + }, + changes: [ + { + caption: "Update 'jsx' to 'react'", + change: sys => sys.writeFile(`${projectRoot}/tsconfig.json`, '{ "compilerOptions": { "jsx": "react" } }'), + timeouts: runQueuedTimeoutCallbacks, + }, + ] + }); }); } diff --git a/tests/baselines/reference/tscWatch/programUpdates/updates-emit-on-jsx-option-change.js b/tests/baselines/reference/tscWatch/programUpdates/updates-emit-on-jsx-option-change.js new file mode 100644 index 00000000000..cb813971b8f --- /dev/null +++ b/tests/baselines/reference/tscWatch/programUpdates/updates-emit-on-jsx-option-change.js @@ -0,0 +1,109 @@ +Input:: +//// [/user/username/projects/myproject/index.tsx] +declare var React: any; +const d =
; + +//// [/user/username/projects/myproject/tsconfig.json] +{"compilerOptions":{"jsx":"preserve"}} + +//// [/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/lib/tsc.js -w +Output:: +>> Screen clear +[12:00:21 AM] Starting compilation in watch mode... + +[12:00:24 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/index.tsx"] +Program options: {"jsx":1,"watch":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/index.tsx + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/index.tsx + +WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"fileName":"/user/username/projects/myproject/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/index.tsx: + {"fileName":"/user/username/projects/myproject/index.tsx","pollingInterval":250} +/a/lib/lib.d.ts: + {"fileName":"/a/lib/lib.d.ts","pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: +/user/username/projects/myproject/node_modules/@types: + {"directoryName":"/user/username/projects/myproject/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} +/user/username/projects/myproject: + {"directoryName":"/user/username/projects/myproject","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/index.jsx] +var d =
; + + + +Change:: Update 'jsx' to 'react' + +Input:: +//// [/user/username/projects/myproject/tsconfig.json] +{ "compilerOptions": { "jsx": "react" } } + + +Output:: +>> Screen clear +[12:00:28 AM] File change detected. Starting incremental compilation... + +[12:00:31 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/index.tsx"] +Program options: {"jsx":2,"watch":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/index.tsx + +Semantic diagnostics in builder refreshed for:: + +WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"fileName":"/user/username/projects/myproject/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/index.tsx: + {"fileName":"/user/username/projects/myproject/index.tsx","pollingInterval":250} +/a/lib/lib.d.ts: + {"fileName":"/a/lib/lib.d.ts","pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: +/user/username/projects/myproject/node_modules/@types: + {"directoryName":"/user/username/projects/myproject/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} +/user/username/projects/myproject: + {"directoryName":"/user/username/projects/myproject","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/index.js] +var d = React.createElement("div", null); + +