Skip to content

Commit dc8952d

Browse files
authored
jsx option affects emit (microsoft#40775)
1 parent b508914 commit dc8952d

File tree

3 files changed

+138
-0
lines changed

3 files changed

+138
-0
lines changed

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ namespace ts {
380380
name: "jsx",
381381
type: jsxOptionMap,
382382
affectsSourceFile: true,
383+
affectsEmit: true,
383384
paramType: Diagnostics.KIND,
384385
showInSimplifiedHelpView: true,
385386
category: Diagnostics.Basic_Options,

src/testRunner/unittests/tscWatch/programUpdates.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,5 +1598,33 @@ import { x } from "../b";`),
15981598
},
15991599
]
16001600
});
1601+
1602+
verifyTscWatch({
1603+
scenario,
1604+
subScenario: "updates emit on jsx option change",
1605+
commandLineArgs: ["-w"],
1606+
sys: () => {
1607+
const index: File = {
1608+
path: `${projectRoot}/index.tsx`,
1609+
content: `declare var React: any;\nconst d = <div />;`
1610+
};
1611+
const configFile: File = {
1612+
path: `${projectRoot}/tsconfig.json`,
1613+
content: JSON.stringify({
1614+
compilerOptions: {
1615+
jsx: "preserve"
1616+
}
1617+
})
1618+
};
1619+
return createWatchedSystem([index, configFile, libFile], { currentDirectory: projectRoot });
1620+
},
1621+
changes: [
1622+
{
1623+
caption: "Update 'jsx' to 'react'",
1624+
change: sys => sys.writeFile(`${projectRoot}/tsconfig.json`, '{ "compilerOptions": { "jsx": "react" } }'),
1625+
timeouts: runQueuedTimeoutCallbacks,
1626+
},
1627+
]
1628+
});
16011629
});
16021630
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
Input::
2+
//// [/user/username/projects/myproject/index.tsx]
3+
declare var React: any;
4+
const d = <div />;
5+
6+
//// [/user/username/projects/myproject/tsconfig.json]
7+
{"compilerOptions":{"jsx":"preserve"}}
8+
9+
//// [/a/lib/lib.d.ts]
10+
/// <reference no-default-lib="true"/>
11+
interface Boolean {}
12+
interface Function {}
13+
interface CallableFunction {}
14+
interface NewableFunction {}
15+
interface IArguments {}
16+
interface Number { toExponential: any; }
17+
interface Object {}
18+
interface RegExp {}
19+
interface String { charAt: any; }
20+
interface Array<T> { length: number; [n: number]: T; }
21+
22+
23+
/a/lib/tsc.js -w
24+
Output::
25+
>> Screen clear
26+
[12:00:21 AM] Starting compilation in watch mode...
27+
28+
[12:00:24 AM] Found 0 errors. Watching for file changes.
29+
30+
31+
32+
Program root files: ["/user/username/projects/myproject/index.tsx"]
33+
Program options: {"jsx":1,"watch":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
34+
Program files::
35+
/a/lib/lib.d.ts
36+
/user/username/projects/myproject/index.tsx
37+
38+
Semantic diagnostics in builder refreshed for::
39+
/a/lib/lib.d.ts
40+
/user/username/projects/myproject/index.tsx
41+
42+
WatchedFiles::
43+
/user/username/projects/myproject/tsconfig.json:
44+
{"fileName":"/user/username/projects/myproject/tsconfig.json","pollingInterval":250}
45+
/user/username/projects/myproject/index.tsx:
46+
{"fileName":"/user/username/projects/myproject/index.tsx","pollingInterval":250}
47+
/a/lib/lib.d.ts:
48+
{"fileName":"/a/lib/lib.d.ts","pollingInterval":250}
49+
50+
FsWatches::
51+
52+
FsWatchesRecursive::
53+
/user/username/projects/myproject/node_modules/@types:
54+
{"directoryName":"/user/username/projects/myproject/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
55+
/user/username/projects/myproject:
56+
{"directoryName":"/user/username/projects/myproject","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
57+
58+
exitCode:: ExitStatus.undefined
59+
60+
//// [/user/username/projects/myproject/index.jsx]
61+
var d = <div />;
62+
63+
64+
65+
Change:: Update 'jsx' to 'react'
66+
67+
Input::
68+
//// [/user/username/projects/myproject/tsconfig.json]
69+
{ "compilerOptions": { "jsx": "react" } }
70+
71+
72+
Output::
73+
>> Screen clear
74+
[12:00:28 AM] File change detected. Starting incremental compilation...
75+
76+
[12:00:31 AM] Found 0 errors. Watching for file changes.
77+
78+
79+
80+
Program root files: ["/user/username/projects/myproject/index.tsx"]
81+
Program options: {"jsx":2,"watch":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
82+
Program files::
83+
/a/lib/lib.d.ts
84+
/user/username/projects/myproject/index.tsx
85+
86+
Semantic diagnostics in builder refreshed for::
87+
88+
WatchedFiles::
89+
/user/username/projects/myproject/tsconfig.json:
90+
{"fileName":"/user/username/projects/myproject/tsconfig.json","pollingInterval":250}
91+
/user/username/projects/myproject/index.tsx:
92+
{"fileName":"/user/username/projects/myproject/index.tsx","pollingInterval":250}
93+
/a/lib/lib.d.ts:
94+
{"fileName":"/a/lib/lib.d.ts","pollingInterval":250}
95+
96+
FsWatches::
97+
98+
FsWatchesRecursive::
99+
/user/username/projects/myproject/node_modules/@types:
100+
{"directoryName":"/user/username/projects/myproject/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
101+
/user/username/projects/myproject:
102+
{"directoryName":"/user/username/projects/myproject","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
103+
104+
exitCode:: ExitStatus.undefined
105+
106+
//// [/user/username/projects/myproject/index.js]
107+
var d = React.createElement("div", null);
108+
109+

0 commit comments

Comments
 (0)