Skip to content

Commit 187095e

Browse files
committed
Baseline without the actual implementation of the flag
1 parent 85ef91e commit 187095e

File tree

8 files changed

+290
-0
lines changed

8 files changed

+290
-0
lines changed

src/compiler/commandLineParser.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,13 @@ namespace ts {
236236
category: Diagnostics.Advanced_Options,
237237
description: Diagnostics.Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it
238238
},
239+
{
240+
name: "assumeChangesAffectShape",
241+
type: "boolean",
242+
affectsEmit: true,
243+
category: Diagnostics.Advanced_Options,
244+
description: Diagnostics.Have_recompiles_in_incremental_and_watch_assume_that_any_change_to_file_can_affect_its_shape_resulting_in_affecting_it_s_dependecies
245+
},
239246
{
240247
name: "locale",
241248
type: "string",

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4719,6 +4719,10 @@
47194719
"code": 6385,
47204720
"reportsDeprecated": true
47214721
},
4722+
"Have recompiles in '--incremental' and '--watch' assume that any change to file can affect its shape resulting in affecting it's dependecies.": {
4723+
"category": "Message",
4724+
"code": 6386
4725+
},
47224726

47234727
"The expected type comes from property '{0}' which is declared here on type '{1}'": {
47244728
"category": "Message",

src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5784,6 +5784,7 @@ namespace ts {
57845784
noUnusedParameters?: boolean;
57855785
noImplicitUseStrict?: boolean;
57865786
assumeChangesOnlyAffectDirectDependencies?: boolean;
5787+
assumeChangesAffectShape?: boolean;
57875788
noLib?: boolean;
57885789
noResolve?: boolean;
57895790
noUncheckedIndexedAccess?: boolean;

src/testRunner/unittests/tsc/incremental.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,5 +235,32 @@ const a: string = 10;`, "utf-8"),
235235
}
236236
}
237237
});
238+
239+
verifyTscSerializedIncrementalEdits({
240+
scenario: "incremental",
241+
subScenario: "assumeChangesAffectShape",
242+
fs: () => loadProjectFromFiles({
243+
"/src/project/main.ts": `import { foo } from "./module";foo();`,
244+
"/src/project/module.ts": `export function foo(): string { return "hello"; }`,
245+
"/src/project/extraFile.ts": "export const extra = 10;",
246+
"/src/project/tsconfig.json": JSON.stringify({
247+
compilerOptions: { assumeChangesAffectShape: true }
248+
})
249+
}),
250+
commandLineArgs: ["--incremental", "--p", "src/project"],
251+
incrementalScenarios: [
252+
{
253+
subScenario: "Local edit to module",
254+
modifyFs: fs => replaceText(fs, "/src/project/module.ts", "hello", "hello world"),
255+
buildKind: BuildKind.IncrementalDtsUnchanged
256+
},
257+
{
258+
subScenario: "Api change edit to module",
259+
modifyFs: fs => prependText(fs, "/src/project/module.ts", "export const x = 10;"),
260+
buildKind: BuildKind.IncrementalDtsUnchanged
261+
},
262+
]
263+
});
264+
238265
});
239266
}

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2833,6 +2833,7 @@ declare namespace ts {
28332833
noUnusedParameters?: boolean;
28342834
noImplicitUseStrict?: boolean;
28352835
assumeChangesOnlyAffectDirectDependencies?: boolean;
2836+
assumeChangesAffectShape?: boolean;
28362837
noLib?: boolean;
28372838
noResolve?: boolean;
28382839
noUncheckedIndexedAccess?: boolean;

tests/baselines/reference/api/typescript.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2833,6 +2833,7 @@ declare namespace ts {
28332833
noUnusedParameters?: boolean;
28342834
noImplicitUseStrict?: boolean;
28352835
assumeChangesOnlyAffectDirectDependencies?: boolean;
2836+
assumeChangesAffectShape?: boolean;
28362837
noLib?: boolean;
28372838
noResolve?: boolean;
28382839
noUncheckedIndexedAccess?: boolean;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"compilerOptions": {
3+
"assumeChangesAffectShape": true
4+
}
5+
}
Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
Input::
2+
//// [/lib/lib.d.ts]
3+
/// <reference no-default-lib="true"/>
4+
interface Boolean {}
5+
interface Function {}
6+
interface CallableFunction {}
7+
interface NewableFunction {}
8+
interface IArguments {}
9+
interface Number { toExponential: any; }
10+
interface Object {}
11+
interface RegExp {}
12+
interface String { charAt: any; }
13+
interface Array<T> { length: number; [n: number]: T; }
14+
interface ReadonlyArray<T> {}
15+
declare const console: { log(msg: any): void; };
16+
17+
//// [/src/project/extraFile.ts]
18+
export const extra = 10;
19+
20+
//// [/src/project/main.ts]
21+
import { foo } from "./module";foo();
22+
23+
//// [/src/project/module.ts]
24+
export function foo(): string { return "hello"; }
25+
26+
//// [/src/project/tsconfig.json]
27+
{"compilerOptions":{"assumeChangesAffectShape":true}}
28+
29+
30+
31+
Output::
32+
/lib/tsc --incremental --p src/project
33+
exitCode:: ExitStatus.Success
34+
35+
36+
//// [/src/project/extraFile.js]
37+
"use strict";
38+
exports.__esModule = true;
39+
exports.extra = void 0;
40+
exports.extra = 10;
41+
42+
43+
//// [/src/project/main.js]
44+
"use strict";
45+
exports.__esModule = true;
46+
var module_1 = require("./module");
47+
module_1.foo();
48+
49+
50+
//// [/src/project/module.js]
51+
"use strict";
52+
exports.__esModule = true;
53+
exports.foo = void 0;
54+
function foo() { return "hello"; }
55+
exports.foo = foo;
56+
57+
58+
//// [/src/project/tsconfig.tsbuildinfo]
59+
{
60+
"program": {
61+
"fileInfos": {
62+
"../../lib/lib.d.ts": {
63+
"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; };",
64+
"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; };",
65+
"affectsGlobalScope": true
66+
},
67+
"./extrafile.ts": {
68+
"version": "-13403012629-export const extra = 10;",
69+
"signature": "-4859189518-export declare const extra = 10;\r\n",
70+
"affectsGlobalScope": false
71+
},
72+
"./module.ts": {
73+
"version": "-8446458946-export function foo(): string { return \"hello\"; }",
74+
"signature": "-8035635627-export declare function foo(): string;\r\n",
75+
"affectsGlobalScope": false
76+
},
77+
"./main.ts": {
78+
"version": "-7083766686-import { foo } from \"./module\";foo();",
79+
"signature": "-4882119183-export {};\r\n",
80+
"affectsGlobalScope": false
81+
}
82+
},
83+
"options": {
84+
"assumeChangesAffectShape": true,
85+
"incremental": true,
86+
"project": "./",
87+
"configFilePath": "./tsconfig.json"
88+
},
89+
"referencedMap": {
90+
"./main.ts": [
91+
"./module.ts"
92+
]
93+
},
94+
"exportedModulesMap": {},
95+
"semanticDiagnosticsPerFile": [
96+
"../../lib/lib.d.ts",
97+
"./extrafile.ts",
98+
"./main.ts",
99+
"./module.ts"
100+
]
101+
},
102+
"version": "FakeTSVersion"
103+
}
104+
105+
106+
107+
Change:: Local edit to module
108+
Input::
109+
//// [/src/project/module.ts]
110+
export function foo(): string { return "hello world"; }
111+
112+
113+
114+
Output::
115+
/lib/tsc --incremental --p src/project
116+
exitCode:: ExitStatus.Success
117+
118+
119+
//// [/src/project/module.js]
120+
"use strict";
121+
exports.__esModule = true;
122+
exports.foo = void 0;
123+
function foo() { return "hello world"; }
124+
exports.foo = foo;
125+
126+
127+
//// [/src/project/tsconfig.tsbuildinfo]
128+
{
129+
"program": {
130+
"fileInfos": {
131+
"../../lib/lib.d.ts": {
132+
"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; };",
133+
"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; };",
134+
"affectsGlobalScope": true
135+
},
136+
"./extrafile.ts": {
137+
"version": "-13403012629-export const extra = 10;",
138+
"signature": "-4859189518-export declare const extra = 10;\r\n",
139+
"affectsGlobalScope": false
140+
},
141+
"./module.ts": {
142+
"version": "-4300970970-export function foo(): string { return \"hello world\"; }",
143+
"signature": "-8035635627-export declare function foo(): string;\r\n",
144+
"affectsGlobalScope": false
145+
},
146+
"./main.ts": {
147+
"version": "-7083766686-import { foo } from \"./module\";foo();",
148+
"signature": "-4882119183-export {};\r\n",
149+
"affectsGlobalScope": false
150+
}
151+
},
152+
"options": {
153+
"assumeChangesAffectShape": true,
154+
"incremental": true,
155+
"project": "./",
156+
"configFilePath": "./tsconfig.json"
157+
},
158+
"referencedMap": {
159+
"./main.ts": [
160+
"./module.ts"
161+
]
162+
},
163+
"exportedModulesMap": {},
164+
"semanticDiagnosticsPerFile": [
165+
"../../lib/lib.d.ts",
166+
"./extrafile.ts",
167+
"./main.ts",
168+
"./module.ts"
169+
]
170+
},
171+
"version": "FakeTSVersion"
172+
}
173+
174+
175+
176+
Change:: Api change edit to module
177+
Input::
178+
//// [/src/project/module.ts]
179+
export const x = 10;export function foo(): string { return "hello world"; }
180+
181+
182+
183+
Output::
184+
/lib/tsc --incremental --p src/project
185+
exitCode:: ExitStatus.Success
186+
187+
188+
//// [/src/project/main.js] file written with same contents
189+
//// [/src/project/module.js]
190+
"use strict";
191+
exports.__esModule = true;
192+
exports.foo = exports.x = void 0;
193+
exports.x = 10;
194+
function foo() { return "hello world"; }
195+
exports.foo = foo;
196+
197+
198+
//// [/src/project/tsconfig.tsbuildinfo]
199+
{
200+
"program": {
201+
"fileInfos": {
202+
"../../lib/lib.d.ts": {
203+
"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; };",
204+
"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; };",
205+
"affectsGlobalScope": true
206+
},
207+
"./extrafile.ts": {
208+
"version": "-13403012629-export const extra = 10;",
209+
"signature": "-4859189518-export declare const extra = 10;\r\n",
210+
"affectsGlobalScope": false
211+
},
212+
"./module.ts": {
213+
"version": "-1237933216-export const x = 10;export function foo(): string { return \"hello world\"; }",
214+
"signature": "1387636182-export declare const x = 10;\r\nexport declare function foo(): string;\r\n",
215+
"affectsGlobalScope": false
216+
},
217+
"./main.ts": {
218+
"version": "-7083766686-import { foo } from \"./module\";foo();",
219+
"signature": "-4882119183-export {};\r\n",
220+
"affectsGlobalScope": false
221+
}
222+
},
223+
"options": {
224+
"assumeChangesAffectShape": true,
225+
"incremental": true,
226+
"project": "./",
227+
"configFilePath": "./tsconfig.json"
228+
},
229+
"referencedMap": {
230+
"./main.ts": [
231+
"./module.ts"
232+
]
233+
},
234+
"exportedModulesMap": {},
235+
"semanticDiagnosticsPerFile": [
236+
"../../lib/lib.d.ts",
237+
"./extrafile.ts",
238+
"./main.ts",
239+
"./module.ts"
240+
]
241+
},
242+
"version": "FakeTSVersion"
243+
}
244+

0 commit comments

Comments
 (0)