Compare commits

...

3 commits

Author SHA1 Message Date
Sheetal Nandi 4028fbe397 Merge branch 'master' into assumeChangesAffectShape 2021-05-07 11:51:46 -07:00
Sheetal Nandi d52da06f4f Implement assumeChangesAffectShape which means any change to file can affect the dependencies
This avoids having to generate d.ts files for the sources
2021-05-05 12:45:24 -07:00
Sheetal Nandi c61bc85b1c Baseline without the actual implementation of the flag 2021-05-05 12:41:00 -07:00
9 changed files with 406 additions and 1 deletions

View file

@ -243,7 +243,8 @@ namespace ts {
referencedMap,
exportedModulesMap,
hasCalledUpdateShapeSignature,
useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState
useFileVersionAsSignature: (!disableUseFileVersionAsSignature && !useOldState) ||
!!newProgram.getCompilerOptions().assumeChangesAffectShape,
};
}

View file

@ -272,6 +272,12 @@ namespace ts {
category: Diagnostics.Advanced_Options,
description: Diagnostics.Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it
},
{
name: "assumeChangesAffectShape",
type: "boolean",
category: Diagnostics.Advanced_Options,
description: Diagnostics.Have_recompiles_in_incremental_and_watch_assume_that_any_change_to_file_can_affect_its_shape_resulting_in_affecting_it_s_dependecies
},
{
name: "locale",
type: "string",

View file

@ -5061,6 +5061,10 @@
"category": "Message",
"code": 6388
},
"Have recompiles in '--incremental' and '--watch' assume that any change to file can affect its shape resulting in affecting it's dependecies.": {
"category": "Message",
"code": 6389
},
"The expected type comes from property '{0}' which is declared here on type '{1}'": {
"category": "Message",

View file

@ -5965,6 +5965,7 @@ namespace ts {
noImplicitUseStrict?: boolean;
noPropertyAccessFromIndexSignature?: boolean;
assumeChangesOnlyAffectDirectDependencies?: boolean;
assumeChangesAffectShape?: boolean;
noLib?: boolean;
noResolve?: boolean;
noUncheckedIndexedAccess?: boolean;

View file

@ -293,6 +293,37 @@ const a: string = 10;`, "utf-8"),
baselinePrograms: true,
});
verifyTscSerializedIncrementalEdits({
scenario: "incremental",
subScenario: "assumeChangesAffectShape",
fs: () => loadProjectFromFiles({
"/src/project/main.ts": `import { foo } from "./module";foo();`,
"/src/project/module.ts": `export function foo(): string { return "hello"; }`,
"/src/project/extraFile.ts": "export const extra = 10;",
"/src/project/tsconfig.json": JSON.stringify({
compilerOptions: { assumeChangesAffectShape: true }
})
}),
commandLineArgs: ["--incremental", "--p", "src/project"],
incrementalScenarios: [
{
subScenario: "Local edit to module",
modifyFs: fs => replaceText(fs, "/src/project/module.ts", "hello", "hello world"),
buildKind: BuildKind.IncrementalDtsUnchanged
},
{
subScenario: "Local edit to module again",
modifyFs: fs => replaceText(fs, "/src/project/module.ts", "hello", "hello world"),
buildKind: BuildKind.IncrementalDtsUnchanged
},
{
subScenario: "Api change edit to module",
modifyFs: fs => prependText(fs, "/src/project/module.ts", "export const x = 10;"),
buildKind: BuildKind.IncrementalDtsUnchanged
},
]
});
describe("when synthesized imports are added to files", () => {
function getJsxLibraryContent() {
return `

View file

@ -2861,6 +2861,7 @@ declare namespace ts {
noImplicitUseStrict?: boolean;
noPropertyAccessFromIndexSignature?: boolean;
assumeChangesOnlyAffectDirectDependencies?: boolean;
assumeChangesAffectShape?: boolean;
noLib?: boolean;
noResolve?: boolean;
noUncheckedIndexedAccess?: boolean;

View file

@ -2861,6 +2861,7 @@ declare namespace ts {
noImplicitUseStrict?: boolean;
noPropertyAccessFromIndexSignature?: boolean;
assumeChangesOnlyAffectDirectDependencies?: boolean;
assumeChangesAffectShape?: boolean;
noLib?: boolean;
noResolve?: boolean;
noUncheckedIndexedAccess?: boolean;

View file

@ -0,0 +1,5 @@
{
"compilerOptions": {
"assumeChangesAffectShape": true
}
}

View file

@ -0,0 +1,355 @@
Input::
//// [/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; };
//// [/src/project/extraFile.ts]
export const extra = 10;
//// [/src/project/main.ts]
import { foo } from "./module";foo();
//// [/src/project/module.ts]
export function foo(): string { return "hello"; }
//// [/src/project/tsconfig.json]
{"compilerOptions":{"assumeChangesAffectShape":true}}
Output::
/lib/tsc --incremental --p src/project
exitCode:: ExitStatus.Success
//// [/src/project/extraFile.js]
"use strict";
exports.__esModule = true;
exports.extra = void 0;
exports.extra = 10;
//// [/src/project/main.js]
"use strict";
exports.__esModule = true;
var module_1 = require("./module");
(0, module_1.foo)();
//// [/src/project/module.js]
"use strict";
exports.__esModule = true;
exports.foo = void 0;
function foo() { return "hello"; }
exports.foo = foo;
//// [/src/project/tsconfig.tsbuildinfo]
{"program":{"fileNames":["../../lib/lib.d.ts","./extrafile.ts","./module.ts","./main.ts"],"fileInfos":[{"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; };","affectsGlobalScope":true},"-13403012629-export const extra = 10;","-8446458946-export function foo(): string { return \"hello\"; }","-7083766686-import { foo } from \"./module\";foo();"],"fileIdsList":[[3]],"referencedMap":[[4,1]],"exportedModulesMap":[[4,1]],"semanticDiagnosticsPerFile":[1,2,4,3]},"version":"FakeTSVersion"}
//// [/src/project/tsconfig.tsbuildinfo.readable.baseline.txt]
{
"program": {
"fileNames": [
"../../lib/lib.d.ts",
"./extrafile.ts",
"./module.ts",
"./main.ts"
],
"fileNamesList": [
[
"./module.ts"
]
],
"fileInfos": {
"../../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
},
"./extrafile.ts": {
"version": "-13403012629-export const extra = 10;",
"signature": "-13403012629-export const extra = 10;"
},
"./module.ts": {
"version": "-8446458946-export function foo(): string { return \"hello\"; }",
"signature": "-8446458946-export function foo(): string { return \"hello\"; }"
},
"./main.ts": {
"version": "-7083766686-import { foo } from \"./module\";foo();",
"signature": "-7083766686-import { foo } from \"./module\";foo();"
}
},
"referencedMap": {
"./main.ts": [
"./module.ts"
]
},
"exportedModulesMap": {
"./main.ts": [
"./module.ts"
]
},
"semanticDiagnosticsPerFile": [
"../../lib/lib.d.ts",
"./extrafile.ts",
"./main.ts",
"./module.ts"
]
},
"version": "FakeTSVersion",
"size": 882
}
Change:: Local edit to module
Input::
//// [/src/project/module.ts]
export function foo(): string { return "hello world"; }
Output::
/lib/tsc --incremental --p src/project
exitCode:: ExitStatus.Success
//// [/src/project/main.js] file written with same contents
//// [/src/project/module.js]
"use strict";
exports.__esModule = true;
exports.foo = void 0;
function foo() { return "hello world"; }
exports.foo = foo;
//// [/src/project/tsconfig.tsbuildinfo]
{"program":{"fileNames":["../../lib/lib.d.ts","./extrafile.ts","./module.ts","./main.ts"],"fileInfos":[{"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; };","affectsGlobalScope":true},"-13403012629-export const extra = 10;","-4300970970-export function foo(): string { return \"hello world\"; }","-7083766686-import { foo } from \"./module\";foo();"],"fileIdsList":[[3]],"referencedMap":[[4,1]],"exportedModulesMap":[[4,1]],"semanticDiagnosticsPerFile":[1,2,4,3]},"version":"FakeTSVersion"}
//// [/src/project/tsconfig.tsbuildinfo.readable.baseline.txt]
{
"program": {
"fileNames": [
"../../lib/lib.d.ts",
"./extrafile.ts",
"./module.ts",
"./main.ts"
],
"fileNamesList": [
[
"./module.ts"
]
],
"fileInfos": {
"../../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
},
"./extrafile.ts": {
"version": "-13403012629-export const extra = 10;",
"signature": "-13403012629-export const extra = 10;"
},
"./module.ts": {
"version": "-4300970970-export function foo(): string { return \"hello world\"; }",
"signature": "-4300970970-export function foo(): string { return \"hello world\"; }"
},
"./main.ts": {
"version": "-7083766686-import { foo } from \"./module\";foo();",
"signature": "-7083766686-import { foo } from \"./module\";foo();"
}
},
"referencedMap": {
"./main.ts": [
"./module.ts"
]
},
"exportedModulesMap": {
"./main.ts": [
"./module.ts"
]
},
"semanticDiagnosticsPerFile": [
"../../lib/lib.d.ts",
"./extrafile.ts",
"./main.ts",
"./module.ts"
]
},
"version": "FakeTSVersion",
"size": 888
}
Change:: Local edit to module again
Input::
//// [/src/project/module.ts]
export function foo(): string { return "hello world world"; }
Output::
/lib/tsc --incremental --p src/project
exitCode:: ExitStatus.Success
//// [/src/project/main.js] file written with same contents
//// [/src/project/module.js]
"use strict";
exports.__esModule = true;
exports.foo = void 0;
function foo() { return "hello world world"; }
exports.foo = foo;
//// [/src/project/tsconfig.tsbuildinfo]
{"program":{"fileNames":["../../lib/lib.d.ts","./extrafile.ts","./module.ts","./main.ts"],"fileInfos":[{"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; };","affectsGlobalScope":true},"-13403012629-export const extra = 10;","-3334720882-export function foo(): string { return \"hello world world\"; }","-7083766686-import { foo } from \"./module\";foo();"],"fileIdsList":[[3]],"referencedMap":[[4,1]],"exportedModulesMap":[[4,1]],"semanticDiagnosticsPerFile":[1,2,4,3]},"version":"FakeTSVersion"}
//// [/src/project/tsconfig.tsbuildinfo.readable.baseline.txt]
{
"program": {
"fileNames": [
"../../lib/lib.d.ts",
"./extrafile.ts",
"./module.ts",
"./main.ts"
],
"fileNamesList": [
[
"./module.ts"
]
],
"fileInfos": {
"../../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
},
"./extrafile.ts": {
"version": "-13403012629-export const extra = 10;",
"signature": "-13403012629-export const extra = 10;"
},
"./module.ts": {
"version": "-3334720882-export function foo(): string { return \"hello world world\"; }",
"signature": "-3334720882-export function foo(): string { return \"hello world world\"; }"
},
"./main.ts": {
"version": "-7083766686-import { foo } from \"./module\";foo();",
"signature": "-7083766686-import { foo } from \"./module\";foo();"
}
},
"referencedMap": {
"./main.ts": [
"./module.ts"
]
},
"exportedModulesMap": {
"./main.ts": [
"./module.ts"
]
},
"semanticDiagnosticsPerFile": [
"../../lib/lib.d.ts",
"./extrafile.ts",
"./main.ts",
"./module.ts"
]
},
"version": "FakeTSVersion",
"size": 894
}
Change:: Api change edit to module
Input::
//// [/src/project/module.ts]
export const x = 10;export function foo(): string { return "hello world world"; }
Output::
/lib/tsc --incremental --p src/project
exitCode:: ExitStatus.Success
//// [/src/project/main.js] file written with same contents
//// [/src/project/module.js]
"use strict";
exports.__esModule = true;
exports.foo = exports.x = void 0;
exports.x = 10;
function foo() { return "hello world world"; }
exports.foo = foo;
//// [/src/project/tsconfig.tsbuildinfo]
{"program":{"fileNames":["../../lib/lib.d.ts","./extrafile.ts","./module.ts","./main.ts"],"fileInfos":[{"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; };","affectsGlobalScope":true},"-13403012629-export const extra = 10;","-3842804408-export const x = 10;export function foo(): string { return \"hello world world\"; }","-7083766686-import { foo } from \"./module\";foo();"],"fileIdsList":[[3]],"referencedMap":[[4,1]],"exportedModulesMap":[[4,1]],"semanticDiagnosticsPerFile":[1,2,4,3]},"version":"FakeTSVersion"}
//// [/src/project/tsconfig.tsbuildinfo.readable.baseline.txt]
{
"program": {
"fileNames": [
"../../lib/lib.d.ts",
"./extrafile.ts",
"./module.ts",
"./main.ts"
],
"fileNamesList": [
[
"./module.ts"
]
],
"fileInfos": {
"../../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
},
"./extrafile.ts": {
"version": "-13403012629-export const extra = 10;",
"signature": "-13403012629-export const extra = 10;"
},
"./module.ts": {
"version": "-3842804408-export const x = 10;export function foo(): string { return \"hello world world\"; }",
"signature": "-3842804408-export const x = 10;export function foo(): string { return \"hello world world\"; }"
},
"./main.ts": {
"version": "-7083766686-import { foo } from \"./module\";foo();",
"signature": "-7083766686-import { foo } from \"./module\";foo();"
}
},
"referencedMap": {
"./main.ts": [
"./module.ts"
]
},
"exportedModulesMap": {
"./main.ts": [
"./module.ts"
]
},
"semanticDiagnosticsPerFile": [
"../../lib/lib.d.ts",
"./extrafile.ts",
"./main.ts",
"./module.ts"
]
},
"version": "FakeTSVersion",
"size": 914
}