Add mroe incremental-affecting affixes to compiler options, add incremental test for changing jsxImportSource

This commit is contained in:
Wesley Wigham 2020-10-30 16:01:27 -07:00
parent fe3b3436e6
commit 8493ee8824
No known key found for this signature in database
GPG Key ID: D59F87F60C5400C9
4 changed files with 563 additions and 0 deletions

View File

@ -803,6 +803,8 @@ namespace ts {
{
name: "jsxImportSource",
type: "string",
affectsSemanticDiagnostics: true,
affectsEmit: true,
affectsModuleResolution: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react

View File

@ -276,5 +276,33 @@ export interface A {
],
modifyFs: host => host.deleteFile(`${project}/globals.d.ts`)
});
const jsxImportSourceOptions = { module: "commonjs", jsx: "react-jsx", incremental: true, jsxImportSource: "react" };
const jsxLibraryContent = `export namespace JSX {
interface Element {}
interface IntrinsicElements {
div: {
propA?: boolean;
};
}
}
export function jsx(...args: any[]): void;
export function jsxs(...args: any[]): void;
export const Fragment: unique symbol;
`;
verifyIncrementalWatchEmit({
subScenario: "jsxImportSource option changed",
files: () => [
{ path: libFile.path, content: libContent },
{ path: `${project}/node_modules/react/jsx-runtime/index.d.ts`, content: jsxLibraryContent },
{ path: `${project}/node_modules/react/package.json`, content: JSON.stringify({ name: "react", version: "0.0.1" }) },
{ path: `${project}/node_modules/preact/jsx-runtime/index.d.ts`, content: jsxLibraryContent.replace("propA", "propB") },
{ path: `${project}/node_modules/preact/package.json`, content: JSON.stringify({ name: "preact", version: "0.0.1" }) },
{ path: `${project}/index.tsx`, content: `export const App = () => <div propA={true}></div>;` },
{ path: configFile.path, content: JSON.stringify({ compilerOptions: jsxImportSourceOptions }) }
],
modifyFs: host => host.writeFile(configFile.path, JSON.stringify({ compilerOptions: { ...jsxImportSourceOptions, jsxImportSource: "preact" } }))
});
});
}

View File

@ -0,0 +1,248 @@
Input::
//// [/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; }
interface ReadonlyArray<T> {}
declare const console: { log(msg: any): void; };
//// [/users/username/projects/project/node_modules/react/jsx-runtime/index.d.ts]
export namespace JSX {
interface Element {}
interface IntrinsicElements {
div: {
propA?: boolean;
};
}
}
export function jsx(...args: any[]): void;
export function jsxs(...args: any[]): void;
export const Fragment: unique symbol;
//// [/users/username/projects/project/node_modules/react/package.json]
{"name":"react","version":"0.0.1"}
//// [/users/username/projects/project/node_modules/preact/jsx-runtime/index.d.ts]
export namespace JSX {
interface Element {}
interface IntrinsicElements {
div: {
propB?: boolean;
};
}
}
export function jsx(...args: any[]): void;
export function jsxs(...args: any[]): void;
export const Fragment: unique symbol;
//// [/users/username/projects/project/node_modules/preact/package.json]
{"name":"preact","version":"0.0.1"}
//// [/users/username/projects/project/index.tsx]
export const App = () => <div propA={true}></div>;
//// [/users/username/projects/project/tsconfig.json]
{"compilerOptions":{"module":"commonjs","jsx":"react-jsx","incremental":true,"jsxImportSource":"react"}}
/a/lib/tsc.js -i
Output::
Program root files: ["/users/username/projects/project/index.tsx"]
Program options: {"module":1,"jsx":4,"incremental":true,"jsxImportSource":"react","configFilePath":"/users/username/projects/project/tsconfig.json"}
Program structureReused: Not
Program files::
/a/lib/lib.d.ts
/users/username/projects/project/index.tsx
/users/username/projects/project/node_modules/react/jsx-runtime/index.d.ts
Semantic diagnostics in builder refreshed for::
/a/lib/lib.d.ts
/users/username/projects/project/index.tsx
/users/username/projects/project/node_modules/react/jsx-runtime/index.d.ts
WatchedFiles::
FsWatches::
FsWatchesRecursive::
exitCode:: ExitStatus.Success
//// [/users/username/projects/project/index.js]
"use strict";
exports.__esModule = true;
exports.App = void 0;
var jsx_runtime_1 = require("react/jsx-runtime");
var App = function () { return jsx_runtime_1.jsx("div", { propA: true }, void 0); };
exports.App = App;
//// [/users/username/projects/project/tsconfig.tsbuildinfo]
{
"program": {
"fileInfos": {
"../../../../a/lib/lib.d.ts": {
"version": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"signature": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"affectsGlobalScope": true
},
"./index.tsx": {
"version": "-14760199789-export const App = () => <div propA={true}></div>;",
"signature": "-17269688391-export declare const App: () => import(\"react/jsx-runtime\").JSX.Element;\n",
"affectsGlobalScope": false
},
"./node_modules/react/jsx-runtime/index.d.ts": {
"version": "-35656056833-export namespace JSX {\n interface Element {}\n interface IntrinsicElements {\n div: {\n propA?: boolean;\n };\n }\n}\nexport function jsx(...args: any[]): void;\nexport function jsxs(...args: any[]): void;\nexport const Fragment: unique symbol;\n",
"signature": "-35656056833-export namespace JSX {\n interface Element {}\n interface IntrinsicElements {\n div: {\n propA?: boolean;\n };\n }\n}\nexport function jsx(...args: any[]): void;\nexport function jsxs(...args: any[]): void;\nexport const Fragment: unique symbol;\n",
"affectsGlobalScope": false
}
},
"options": {
"module": 1,
"jsx": 4,
"incremental": true,
"jsxImportSource": "react",
"configFilePath": "./tsconfig.json"
},
"referencedMap": {},
"exportedModulesMap": {
"./index.tsx": [
"./node_modules/react/jsx-runtime/index.d.ts"
]
},
"semanticDiagnosticsPerFile": [
"../../../../a/lib/lib.d.ts",
"./index.tsx",
"./node_modules/react/jsx-runtime/index.d.ts"
]
},
"version": "FakeTSVersion"
}
Change::
Input::
//// [/users/username/projects/project/tsconfig.json]
{"compilerOptions":{"module":"commonjs","jsx":"react-jsx","incremental":true,"jsxImportSource":"preact"}}
Output::
index.tsx:1:31 - error TS2322: Type '{ propA: boolean; }' is not assignable to type '{ propB?: boolean; }'.
Property 'propA' does not exist on type '{ propB?: boolean; }'. Did you mean 'propB'?
1 export const App = () => <div propA={true}></div>;
   ~~~~~
Found 1 error.
Program root files: ["/users/username/projects/project/index.tsx"]
Program options: {"module":1,"jsx":4,"incremental":true,"jsxImportSource":"preact","configFilePath":"/users/username/projects/project/tsconfig.json"}
Program structureReused: Not
Program files::
/a/lib/lib.d.ts
/users/username/projects/project/index.tsx
/users/username/projects/project/node_modules/preact/jsx-runtime/index.d.ts
Semantic diagnostics in builder refreshed for::
/a/lib/lib.d.ts
/users/username/projects/project/index.tsx
/users/username/projects/project/node_modules/preact/jsx-runtime/index.d.ts
WatchedFiles::
FsWatches::
FsWatchesRecursive::
exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated
//// [/users/username/projects/project/index.js]
"use strict";
exports.__esModule = true;
exports.App = void 0;
var jsx_runtime_1 = require("preact/jsx-runtime");
var App = function () { return jsx_runtime_1.jsx("div", { propA: true }, void 0); };
exports.App = App;
//// [/users/username/projects/project/tsconfig.tsbuildinfo]
{
"program": {
"fileInfos": {
"../../../../a/lib/lib.d.ts": {
"version": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"signature": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"affectsGlobalScope": true
},
"./index.tsx": {
"version": "-14760199789-export const App = () => <div propA={true}></div>;",
"signature": "-17269688391-export declare const App: () => import(\"react/jsx-runtime\").JSX.Element;\n",
"affectsGlobalScope": false
},
"./node_modules/preact/jsx-runtime/index.d.ts": {
"version": "-17896129664-export namespace JSX {\n interface Element {}\n interface IntrinsicElements {\n div: {\n propB?: boolean;\n };\n }\n}\nexport function jsx(...args: any[]): void;\nexport function jsxs(...args: any[]): void;\nexport const Fragment: unique symbol;\n",
"signature": "-17896129664-export namespace JSX {\n interface Element {}\n interface IntrinsicElements {\n div: {\n propB?: boolean;\n };\n }\n}\nexport function jsx(...args: any[]): void;\nexport function jsxs(...args: any[]): void;\nexport const Fragment: unique symbol;\n",
"affectsGlobalScope": false
}
},
"options": {
"module": 1,
"jsx": 4,
"incremental": true,
"jsxImportSource": "preact",
"configFilePath": "./tsconfig.json"
},
"referencedMap": {},
"exportedModulesMap": {
"./index.tsx": [
"./node_modules/react/jsx-runtime/index.d.ts"
]
},
"semanticDiagnosticsPerFile": [
"../../../../a/lib/lib.d.ts",
[
"./index.tsx",
[
{
"file": "./index.tsx",
"start": 30,
"length": 5,
"code": 2322,
"category": 1,
"messageText": {
"messageText": "Type '{ propA: boolean; }' is not assignable to type '{ propB?: boolean; }'.",
"category": 1,
"code": 2322,
"next": [
{
"messageText": "Property 'propA' does not exist on type '{ propB?: boolean; }'. Did you mean 'propB'?",
"category": 1,
"code": 2551
}
]
}
}
]
],
"./node_modules/preact/jsx-runtime/index.d.ts"
]
},
"version": "FakeTSVersion"
}

View File

@ -0,0 +1,285 @@
Input::
//// [/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; }
interface ReadonlyArray<T> {}
declare const console: { log(msg: any): void; };
//// [/users/username/projects/project/node_modules/react/jsx-runtime/index.d.ts]
export namespace JSX {
interface Element {}
interface IntrinsicElements {
div: {
propA?: boolean;
};
}
}
export function jsx(...args: any[]): void;
export function jsxs(...args: any[]): void;
export const Fragment: unique symbol;
//// [/users/username/projects/project/node_modules/react/package.json]
{"name":"react","version":"0.0.1"}
//// [/users/username/projects/project/node_modules/preact/jsx-runtime/index.d.ts]
export namespace JSX {
interface Element {}
interface IntrinsicElements {
div: {
propB?: boolean;
};
}
}
export function jsx(...args: any[]): void;
export function jsxs(...args: any[]): void;
export const Fragment: unique symbol;
//// [/users/username/projects/project/node_modules/preact/package.json]
{"name":"preact","version":"0.0.1"}
//// [/users/username/projects/project/index.tsx]
export const App = () => <div propA={true}></div>;
//// [/users/username/projects/project/tsconfig.json]
{"compilerOptions":{"module":"commonjs","jsx":"react-jsx","incremental":true,"jsxImportSource":"react"}}
/a/lib/tsc.js -w
Output::
>> Screen clear
[12:00:39 AM] Starting compilation in watch mode...
[12:00:44 AM] Found 0 errors. Watching for file changes.
Program root files: ["/users/username/projects/project/index.tsx"]
Program options: {"module":1,"jsx":4,"incremental":true,"jsxImportSource":"react","watch":true,"configFilePath":"/users/username/projects/project/tsconfig.json"}
Program structureReused: Not
Program files::
/a/lib/lib.d.ts
/users/username/projects/project/index.tsx
/users/username/projects/project/node_modules/react/jsx-runtime/index.d.ts
Semantic diagnostics in builder refreshed for::
/a/lib/lib.d.ts
/users/username/projects/project/index.tsx
/users/username/projects/project/node_modules/react/jsx-runtime/index.d.ts
WatchedFiles::
/users/username/projects/project/tsconfig.json:
{"fileName":"/users/username/projects/project/tsconfig.json","pollingInterval":250}
/users/username/projects/project/index.tsx:
{"fileName":"/users/username/projects/project/index.tsx","pollingInterval":250}
/users/username/projects/project/node_modules/react/jsx-runtime/index.d.ts:
{"fileName":"/users/username/projects/project/node_modules/react/jsx-runtime/index.d.ts","pollingInterval":250}
/a/lib/lib.d.ts:
{"fileName":"/a/lib/lib.d.ts","pollingInterval":250}
FsWatches::
FsWatchesRecursive::
/users/username/projects/project/node_modules:
{"directoryName":"/users/username/projects/project/node_modules","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
/users/username/projects/project/node_modules/@types:
{"directoryName":"/users/username/projects/project/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
/users/username/projects/project:
{"directoryName":"/users/username/projects/project","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
exitCode:: ExitStatus.undefined
//// [/users/username/projects/project/index.js]
"use strict";
exports.__esModule = true;
exports.App = void 0;
var jsx_runtime_1 = require("react/jsx-runtime");
var App = function () { return jsx_runtime_1.jsx("div", { propA: true }, void 0); };
exports.App = App;
//// [/users/username/projects/project/tsconfig.tsbuildinfo]
{
"program": {
"fileInfos": {
"../../../../a/lib/lib.d.ts": {
"version": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"signature": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"affectsGlobalScope": true
},
"./index.tsx": {
"version": "-14760199789-export const App = () => <div propA={true}></div>;",
"signature": "-17269688391-export declare const App: () => import(\"react/jsx-runtime\").JSX.Element;\n",
"affectsGlobalScope": false
},
"./node_modules/react/jsx-runtime/index.d.ts": {
"version": "-35656056833-export namespace JSX {\n interface Element {}\n interface IntrinsicElements {\n div: {\n propA?: boolean;\n };\n }\n}\nexport function jsx(...args: any[]): void;\nexport function jsxs(...args: any[]): void;\nexport const Fragment: unique symbol;\n",
"signature": "-35656056833-export namespace JSX {\n interface Element {}\n interface IntrinsicElements {\n div: {\n propA?: boolean;\n };\n }\n}\nexport function jsx(...args: any[]): void;\nexport function jsxs(...args: any[]): void;\nexport const Fragment: unique symbol;\n",
"affectsGlobalScope": false
}
},
"options": {
"module": 1,
"jsx": 4,
"incremental": true,
"jsxImportSource": "react",
"watch": true,
"configFilePath": "./tsconfig.json"
},
"referencedMap": {},
"exportedModulesMap": {
"./index.tsx": [
"./node_modules/react/jsx-runtime/index.d.ts"
]
},
"semanticDiagnosticsPerFile": [
"../../../../a/lib/lib.d.ts",
"./index.tsx",
"./node_modules/react/jsx-runtime/index.d.ts"
]
},
"version": "FakeTSVersion"
}
Change::
Input::
//// [/users/username/projects/project/tsconfig.json]
{"compilerOptions":{"module":"commonjs","jsx":"react-jsx","incremental":true,"jsxImportSource":"preact"}}
Output::
>> Screen clear
[12:00:48 AM] Starting compilation in watch mode...
index.tsx:1:31 - error TS2322: Type '{ propA: boolean; }' is not assignable to type '{ propB?: boolean; }'.
Property 'propA' does not exist on type '{ propB?: boolean; }'. Did you mean 'propB'?
1 export const App = () => <div propA={true}></div>;
   ~~~~~
[12:00:55 AM] Found 1 error. Watching for file changes.
Program root files: ["/users/username/projects/project/index.tsx"]
Program options: {"module":1,"jsx":4,"incremental":true,"jsxImportSource":"preact","watch":true,"configFilePath":"/users/username/projects/project/tsconfig.json"}
Program structureReused: Not
Program files::
/a/lib/lib.d.ts
/users/username/projects/project/index.tsx
/users/username/projects/project/node_modules/preact/jsx-runtime/index.d.ts
Semantic diagnostics in builder refreshed for::
/a/lib/lib.d.ts
/users/username/projects/project/index.tsx
/users/username/projects/project/node_modules/preact/jsx-runtime/index.d.ts
WatchedFiles::
/users/username/projects/project/tsconfig.json:
{"fileName":"/users/username/projects/project/tsconfig.json","pollingInterval":250}
/users/username/projects/project/index.tsx:
{"fileName":"/users/username/projects/project/index.tsx","pollingInterval":250}
/users/username/projects/project/node_modules/preact/jsx-runtime/index.d.ts:
{"fileName":"/users/username/projects/project/node_modules/preact/jsx-runtime/index.d.ts","pollingInterval":250}
/a/lib/lib.d.ts:
{"fileName":"/a/lib/lib.d.ts","pollingInterval":250}
FsWatches::
FsWatchesRecursive::
/users/username/projects/project/node_modules:
{"directoryName":"/users/username/projects/project/node_modules","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
/users/username/projects/project/node_modules/@types:
{"directoryName":"/users/username/projects/project/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
/users/username/projects/project:
{"directoryName":"/users/username/projects/project","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
exitCode:: ExitStatus.undefined
//// [/users/username/projects/project/index.js]
"use strict";
exports.__esModule = true;
exports.App = void 0;
var jsx_runtime_1 = require("preact/jsx-runtime");
var App = function () { return jsx_runtime_1.jsx("div", { propA: true }, void 0); };
exports.App = App;
//// [/users/username/projects/project/tsconfig.tsbuildinfo]
{
"program": {
"fileInfos": {
"../../../../a/lib/lib.d.ts": {
"version": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"signature": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
"affectsGlobalScope": true
},
"./index.tsx": {
"version": "-14760199789-export const App = () => <div propA={true}></div>;",
"signature": "-17269688391-export declare const App: () => import(\"react/jsx-runtime\").JSX.Element;\n",
"affectsGlobalScope": false
},
"./node_modules/preact/jsx-runtime/index.d.ts": {
"version": "-17896129664-export namespace JSX {\n interface Element {}\n interface IntrinsicElements {\n div: {\n propB?: boolean;\n };\n }\n}\nexport function jsx(...args: any[]): void;\nexport function jsxs(...args: any[]): void;\nexport const Fragment: unique symbol;\n",
"signature": "-17896129664-export namespace JSX {\n interface Element {}\n interface IntrinsicElements {\n div: {\n propB?: boolean;\n };\n }\n}\nexport function jsx(...args: any[]): void;\nexport function jsxs(...args: any[]): void;\nexport const Fragment: unique symbol;\n",
"affectsGlobalScope": false
}
},
"options": {
"module": 1,
"jsx": 4,
"incremental": true,
"jsxImportSource": "preact",
"watch": true,
"configFilePath": "./tsconfig.json"
},
"referencedMap": {},
"exportedModulesMap": {
"./index.tsx": [
"./node_modules/react/jsx-runtime/index.d.ts"
]
},
"semanticDiagnosticsPerFile": [
"../../../../a/lib/lib.d.ts",
[
"./index.tsx",
[
{
"file": "./index.tsx",
"start": 30,
"length": 5,
"code": 2322,
"category": 1,
"messageText": {
"messageText": "Type '{ propA: boolean; }' is not assignable to type '{ propB?: boolean; }'.",
"category": 1,
"code": 2322,
"next": [
{
"messageText": "Property 'propA' does not exist on type '{ propB?: boolean; }'. Did you mean 'propB'?",
"category": 1,
"code": 2551
}
]
}
}
]
],
"./node_modules/preact/jsx-runtime/index.d.ts"
]
},
"version": "FakeTSVersion"
}