mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
jsx option affects emit (#40775)
This commit is contained in:
@@ -380,6 +380,7 @@ namespace ts {
|
||||
name: "jsx",
|
||||
type: jsxOptionMap,
|
||||
affectsSourceFile: true,
|
||||
affectsEmit: true,
|
||||
paramType: Diagnostics.KIND,
|
||||
showInSimplifiedHelpView: true,
|
||||
category: Diagnostics.Basic_Options,
|
||||
|
||||
@@ -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 = <div />;`
|
||||
};
|
||||
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,
|
||||
},
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
Input::
|
||||
//// [/user/username/projects/myproject/index.tsx]
|
||||
declare var React: any;
|
||||
const d = <div />;
|
||||
|
||||
//// [/user/username/projects/myproject/tsconfig.json]
|
||||
{"compilerOptions":{"jsx":"preserve"}}
|
||||
|
||||
//// [/a/lib/lib.d.ts]
|
||||
/// <reference no-default-lib="true"/>
|
||||
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; }
|
||||
|
||||
|
||||
/a/lib/tsc.js -w
|
||||
Output::
|
||||
>> Screen clear
|
||||
[[90m12:00:21 AM[0m] Starting compilation in watch mode...
|
||||
|
||||
[[90m12:00:24 AM[0m] 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 = <div />;
|
||||
|
||||
|
||||
|
||||
Change:: Update 'jsx' to 'react'
|
||||
|
||||
Input::
|
||||
//// [/user/username/projects/myproject/tsconfig.json]
|
||||
{ "compilerOptions": { "jsx": "react" } }
|
||||
|
||||
|
||||
Output::
|
||||
>> Screen clear
|
||||
[[90m12:00:28 AM[0m] File change detected. Starting incremental compilation...
|
||||
|
||||
[[90m12:00:31 AM[0m] 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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user