From ac190d15fdcc3563cab3863f39ea3bdfdded6296 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 20 May 2024 11:44:17 -0700 Subject: [PATCH 1/7] Experiment noChecking when forcing dts emit --- src/compiler/checker.ts | 26 +++++++++++++------------- src/compiler/program.ts | 2 +- src/compiler/types.ts | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a4020504f9c07..687e754ab403b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2428,10 +2428,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return visitEachChild(node, markAsSynthetic, /*context*/ undefined); } - function getEmitResolver(sourceFile: SourceFile, cancellationToken: CancellationToken) { + function getEmitResolver(sourceFile: SourceFile, cancellationToken: CancellationToken, forceDtsEmit?: boolean) { // Ensure we have all the type information in place for this file so that all the // emitter questions of this resolver will return the right information. - getDiagnostics(sourceFile, cancellationToken); + getDiagnostics(sourceFile, cancellationToken, forceDtsEmit); return emitResolver; } @@ -47483,10 +47483,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { tracing?.pop(); } - function checkSourceFile(node: SourceFile) { + function checkSourceFile(node: SourceFile, forceDtsEmit: boolean | undefined) { tracing?.push(tracing.Phase.Check, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); performance.mark("beforeCheck"); - checkSourceFileWorker(node); + checkSourceFileWorker(node, forceDtsEmit); performance.mark("afterCheck"); performance.measure("Check", "beforeCheck", "afterCheck"); tracing?.pop(); @@ -47511,10 +47511,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } // Fully type check a source file and collect the relevant diagnostics. - function checkSourceFileWorker(node: SourceFile) { + function checkSourceFileWorker(node: SourceFile, forceDtsEmit: boolean | undefined) { const links = getNodeLinks(node); if (!(links.flags & NodeCheckFlags.TypeChecked)) { - if (skipTypeChecking(node, compilerOptions, host)) { + if (forceDtsEmit || skipTypeChecking(node, compilerOptions, host)) { return; } @@ -47578,13 +47578,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } - function getDiagnostics(sourceFile: SourceFile, ct: CancellationToken): Diagnostic[] { + function getDiagnostics(sourceFile: SourceFile, ct: CancellationToken, forceDtsEmit?: boolean): Diagnostic[] { try { // Record the cancellation token so it can be checked later on during checkSourceElement. // Do this in a finally block so we can ensure that it gets reset back to nothing after // this call is done. cancellationToken = ct; - return getDiagnosticsWorker(sourceFile); + return getDiagnosticsWorker(sourceFile, forceDtsEmit); } finally { cancellationToken = undefined; @@ -47599,7 +47599,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { deferredDiagnosticsCallbacks = []; } - function checkSourceFileWithEagerDiagnostics(sourceFile: SourceFile) { + function checkSourceFileWithEagerDiagnostics(sourceFile: SourceFile, forceDtsEmit?: boolean) { ensurePendingDiagnosticWorkComplete(); // then setup diagnostics for immediate invocation (as we are about to collect them, and // this avoids the overhead of longer-lived callbacks we don't need to allocate) @@ -47608,11 +47608,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // thus much more likely retaining the same union ordering as before we had lazy diagnostics) const oldAddLazyDiagnostics = addLazyDiagnostic; addLazyDiagnostic = cb => cb(); - checkSourceFile(sourceFile); + checkSourceFile(sourceFile, forceDtsEmit); addLazyDiagnostic = oldAddLazyDiagnostics; } - function getDiagnosticsWorker(sourceFile: SourceFile): Diagnostic[] { + function getDiagnosticsWorker(sourceFile: SourceFile, forceDtsEmit: boolean | undefined): Diagnostic[] { if (sourceFile) { ensurePendingDiagnosticWorkComplete(); // Some global diagnostics are deferred until they are needed and @@ -47621,7 +47621,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics(); const previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length; - checkSourceFileWithEagerDiagnostics(sourceFile); + checkSourceFileWithEagerDiagnostics(sourceFile, forceDtsEmit); const semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); const currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics(); @@ -47642,7 +47642,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // Global diagnostics are always added when a file is not provided to // getDiagnostics - forEach(host.getSourceFiles(), checkSourceFileWithEagerDiagnostics); + forEach(host.getSourceFiles(), sourceFile => checkSourceFileWithEagerDiagnostics(sourceFile, forceDtsEmit)); return diagnostics.getDiagnostics(); } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index dfb878c6265a0..39fb1b7ea338e 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2870,7 +2870,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg // This is because in the -out scenario all files need to be emitted, and therefore all // files need to be type checked. And the way to specify that all files need to be type // checked is to not pass the file to getEmitResolver. - const emitResolver = getTypeChecker().getEmitResolver(options.outFile ? undefined : sourceFile, cancellationToken); + const emitResolver = getTypeChecker().getEmitResolver(options.outFile ? undefined : sourceFile, cancellationToken, forceDtsEmit); performance.mark("beforeEmit"); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index aae7c5494a17d..198bb33fa9902 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5264,7 +5264,7 @@ export interface TypeChecker { // Should not be called directly. Should only be accessed through the Program instance. /** @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; /** @internal */ getGlobalDiagnostics(): Diagnostic[]; - /** @internal */ getEmitResolver(sourceFile?: SourceFile, cancellationToken?: CancellationToken): EmitResolver; + /** @internal */ getEmitResolver(sourceFile?: SourceFile, cancellationToken?: CancellationToken, forceDts?: boolean): EmitResolver; /** @internal */ getNodeCount(): number; /** @internal */ getIdentifierCount(): number; From bf87f2679b1280776e7005878b65eacec4c456dd Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 20 May 2024 11:51:14 -0700 Subject: [PATCH 2/7] Tests failing --- .../demo/updates-with-bad-reference.js | 8 +- .../when-emitting-buildInfo.js | 23 +- .../tsc/cancellationToken/when-using-state.js | 23 +- ...-declaration-emit-enabled-discrepancies.js | 296 ++++++++++++++++++ ...ion-field-with-declaration-emit-enabled.js | 52 ++- 5 files changed, 377 insertions(+), 25 deletions(-) create mode 100644 tests/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled-discrepancies.js diff --git a/tests/baselines/reference/tsbuildWatch/demo/updates-with-bad-reference.js b/tests/baselines/reference/tsbuildWatch/demo/updates-with-bad-reference.js index 42f6c2e900831..49c578d2146b6 100644 --- a/tests/baselines/reference/tsbuildWatch/demo/updates-with-bad-reference.js +++ b/tests/baselines/reference/tsbuildWatch/demo/updates-with-bad-reference.js @@ -556,7 +556,7 @@ Output:: //// [/user/username/projects/demo/lib/core/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../../../../a/lib/lib.d.ts","../../animals/animal.ts","../../animals/dog.ts","../../animals/index.ts","../../core/utilities.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedFormat":1},{"version":"-9289341318-export type Size = \"small\" | \"medium\" | \"large\";\nexport default interface Animal {\n size: Size;\n}\n","impliedFormat":1},{"version":"-18870194049-import Animal from '.';\nimport { makeRandomName } from '../core/utilities';\n\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\n\nexport function createDog(): Dog {\n return ({\n size: \"medium\",\n woof: function(this: Dog) {\n console.log(`${ this.name } says \"Woof\"!`);\n },\n name: makeRandomName()\n });\n}\n","signature":"6032048049-import Animal from '.';\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\nexport declare function createDog(): Dog;\n","impliedFormat":1},{"version":"-7220553464-import Animal from './animal';\n\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n","signature":"1096904574-import Animal from './animal';\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n","impliedFormat":1},{"version":"-11321611519-\nimport * as A from '../animals';\nexport function makeRandomName() {\n return \"Bob!?! \";\n}\n\nexport function lastElementOf(arr: T[]): T | undefined {\n if (arr.length === 0) return undefined;\n return arr[arr.length - 1];\n}\n","signature":"-11345568166-export declare function makeRandomName(): string;\nexport declare function lastElementOf(arr: T[]): T | undefined;\n","impliedFormat":1}],"root":[5],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../core","strict":true,"target":1},"fileIdsList":[[4,5],[2,3],[4]],"referencedMap":[[3,1],[4,2],[5,3]],"semanticDiagnosticsPerFile":[1,2,3,4,[5,[{"file":"../../core/utilities.ts","start":1,"length":32,"messageText":"'A' is declared but its value is never read.","category":1,"code":6133,"reportsUnnecessary":true}]]],"affectedFilesPendingEmit":[2,3,4,5],"emitSignatures":[2,3,4,5]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../../../../a/lib/lib.d.ts","../../animals/animal.ts","../../animals/dog.ts","../../animals/index.ts","../../core/utilities.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedFormat":1},{"version":"-9289341318-export type Size = \"small\" | \"medium\" | \"large\";\nexport default interface Animal {\n size: Size;\n}\n","impliedFormat":1},{"version":"-18870194049-import Animal from '.';\nimport { makeRandomName } from '../core/utilities';\n\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\n\nexport function createDog(): Dog {\n return ({\n size: \"medium\",\n woof: function(this: Dog) {\n console.log(`${ this.name } says \"Woof\"!`);\n },\n name: makeRandomName()\n });\n}\n","signature":"6032048049-import Animal from '.';\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\nexport declare function createDog(): Dog;\n","impliedFormat":1},{"version":"-7220553464-import Animal from './animal';\n\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n","signature":"2198076214-export default Animal;\nexport { createDog, Dog };\n","impliedFormat":1},{"version":"-11321611519-\nimport * as A from '../animals';\nexport function makeRandomName() {\n return \"Bob!?! \";\n}\n\nexport function lastElementOf(arr: T[]): T | undefined {\n if (arr.length === 0) return undefined;\n return arr[arr.length - 1];\n}\n","signature":"-11345568166-export declare function makeRandomName(): string;\nexport declare function lastElementOf(arr: T[]): T | undefined;\n","impliedFormat":1}],"root":[5],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../core","strict":true,"target":1},"fileIdsList":[[4,5],[2,3],[4]],"referencedMap":[[3,1],[4,2],[5,3]],"semanticDiagnosticsPerFile":[1,2,3,4,[5,[{"file":"../../core/utilities.ts","start":1,"length":32,"messageText":"'A' is declared but its value is never read.","category":1,"code":6133,"reportsUnnecessary":true}]]],"affectedFilesPendingEmit":[2,3,4,5],"emitSignatures":[2,3,4,5]},"version":"FakeTSVersion"} //// [/user/username/projects/demo/lib/core/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -615,11 +615,11 @@ Output:: "../../animals/index.ts": { "original": { "version": "-7220553464-import Animal from './animal';\n\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n", - "signature": "1096904574-import Animal from './animal';\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n", + "signature": "2198076214-export default Animal;\nexport { createDog, Dog };\n", "impliedFormat": 1 }, "version": "-7220553464-import Animal from './animal';\n\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n", - "signature": "1096904574-import Animal from './animal';\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n", + "signature": "2198076214-export default Animal;\nexport { createDog, Dog };\n", "impliedFormat": "commonjs" }, "../../core/utilities.ts": { @@ -711,7 +711,7 @@ Output:: ] }, "version": "FakeTSVersion", - "size": 2812 + "size": 2739 } diff --git a/tests/baselines/reference/tsc/cancellationToken/when-emitting-buildInfo.js b/tests/baselines/reference/tsc/cancellationToken/when-emitting-buildInfo.js index 5c9a2900a5b8f..b6dff17c055ef 100644 --- a/tests/baselines/reference/tsc/cancellationToken/when-emitting-buildInfo.js +++ b/tests/baselines/reference/tsc/cancellationToken/when-emitting-buildInfo.js @@ -273,7 +273,7 @@ Operation ws cancelled:: true //// [/user/username/projects/myproject/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./c.ts","./b.ts","./a.ts","./d.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"840271342-export class C {\n d = 1;\n}export function foo() {}","signature":"-6977846840-export declare class C {\n d: number;\n}\n","impliedFormat":1},{"version":"-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}","signature":"-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n","impliedFormat":1},{"version":"4878398349-import {B} from './b';\ndeclare var console: any;\nlet b = new B();\nconsole.log(b.c.d);","signature":"-3531856636-export {};\n","impliedFormat":1},{"version":"-7804761415-export class D { }","signature":"-8611429667-export declare class D {\n}\n","impliedFormat":1}],"root":[[2,5]],"options":{"declaration":true},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,4,3,5],"changeFileSet":[2]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./c.ts","./b.ts","./a.ts","./d.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"840271342-export class C {\n d = 1;\n}export function foo() {}","signature":"-6977846840-export declare class C {\n d: number;\n}\n","impliedFormat":1},{"version":"-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}","signature":"-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n","impliedFormat":1},{"version":"4878398349-import {B} from './b';\ndeclare var console: any;\nlet b = new B();\nconsole.log(b.c.d);","signature":"-3531856636-export {};\n","impliedFormat":1},{"version":"-7804761415-export class D { }","signature":"-8611429667-export declare class D {\n}\n","impliedFormat":1}],"root":[[2,5]],"options":{"declaration":true},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,3,5],"affectedFilesPendingEmit":[[4],2],"changeFileSet":[2]},"version":"FakeTSVersion"} //// [/user/username/projects/myproject/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -373,16 +373,27 @@ Operation ws cancelled:: true }, "semanticDiagnosticsPerFile": [ "../../../../a/lib/lib.d.ts", - "./a.ts", "./b.ts", "./d.ts" ], + "affectedFilesPendingEmit": [ + [ + [ + "./a.ts" + ], + "Dts" + ], + [ + "./c.ts", + "Js | Dts" + ] + ], "changeFileSet": [ "./c.ts" ] }, "version": "FakeTSVersion", - "size": 1366 + "size": 1399 } @@ -407,8 +418,12 @@ Program files:: Semantic diagnostics in builder refreshed for:: /user/username/projects/myproject/c.ts +/user/username/projects/myproject/a.ts -No shapes updated in the builder:: +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/c.ts (computed .d.ts) +/user/username/projects/myproject/b.ts (computed .d.ts) +/user/username/projects/myproject/a.ts (used version) exitCode:: ExitStatus.undefined diff --git a/tests/baselines/reference/tsc/cancellationToken/when-using-state.js b/tests/baselines/reference/tsc/cancellationToken/when-using-state.js index 8370dc648cff3..b1e4885668097 100644 --- a/tests/baselines/reference/tsc/cancellationToken/when-using-state.js +++ b/tests/baselines/reference/tsc/cancellationToken/when-using-state.js @@ -273,7 +273,7 @@ Operation ws cancelled:: true //// [/user/username/projects/myproject/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./c.ts","./b.ts","./a.ts","./d.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"840271342-export class C {\n d = 1;\n}export function foo() {}","signature":"-6977846840-export declare class C {\n d: number;\n}\n","impliedFormat":1},{"version":"-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}","signature":"-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n","impliedFormat":1},{"version":"4878398349-import {B} from './b';\ndeclare var console: any;\nlet b = new B();\nconsole.log(b.c.d);","signature":"-3531856636-export {};\n","impliedFormat":1},{"version":"-7804761415-export class D { }","signature":"-8611429667-export declare class D {\n}\n","impliedFormat":1}],"root":[[2,5]],"options":{"declaration":true},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,4,3,5],"changeFileSet":[2]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./c.ts","./b.ts","./a.ts","./d.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"840271342-export class C {\n d = 1;\n}export function foo() {}","signature":"-6977846840-export declare class C {\n d: number;\n}\n","impliedFormat":1},{"version":"-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}","signature":"-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n","impliedFormat":1},{"version":"4878398349-import {B} from './b';\ndeclare var console: any;\nlet b = new B();\nconsole.log(b.c.d);","signature":"-3531856636-export {};\n","impliedFormat":1},{"version":"-7804761415-export class D { }","signature":"-8611429667-export declare class D {\n}\n","impliedFormat":1}],"root":[[2,5]],"options":{"declaration":true},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,3,5],"affectedFilesPendingEmit":[[4],2],"changeFileSet":[2]},"version":"FakeTSVersion"} //// [/user/username/projects/myproject/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -373,16 +373,27 @@ Operation ws cancelled:: true }, "semanticDiagnosticsPerFile": [ "../../../../a/lib/lib.d.ts", - "./a.ts", "./b.ts", "./d.ts" ], + "affectedFilesPendingEmit": [ + [ + [ + "./a.ts" + ], + "Dts" + ], + [ + "./c.ts", + "Js | Dts" + ] + ], "changeFileSet": [ "./c.ts" ] }, "version": "FakeTSVersion", - "size": 1366 + "size": 1399 } @@ -407,8 +418,12 @@ Program files:: Semantic diagnostics in builder refreshed for:: /user/username/projects/myproject/c.ts +/user/username/projects/myproject/a.ts -No shapes updated in the builder:: +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/c.ts (computed .d.ts) +/user/username/projects/myproject/b.ts (computed .d.ts) +/user/username/projects/myproject/a.ts (used version) exitCode:: ExitStatus.undefined diff --git a/tests/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled-discrepancies.js b/tests/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled-discrepancies.js new file mode 100644 index 0000000000000..b1c50c83719ac --- /dev/null +++ b/tests/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled-discrepancies.js @@ -0,0 +1,296 @@ +1:: modify public to protected +*** Needs explanation +Incremental signature is neither dts signature nor file version for File:: ./messageableperson.ts +Incremental:: { + "original": { + "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "signature": "-2474549887-export default MessageablePerson;\n", + "impliedFormat": 1 + }, + "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "signature": "-2474549887-export default MessageablePerson;\n", + "impliedFormat": "commonjs" +} +Clean:: { + "original": { + "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "impliedFormat": 1 + }, + "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "signature": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "impliedFormat": "commonjs" +} +Dts Signature:: $"-21450256696-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n(116,7)Error4094: Property 'message' of exported class expression may not be private or protected." +2:: no-change-run +*** Needs explanation +Incremental signature is neither dts signature nor file version for File:: ./messageableperson.ts +Incremental:: { + "original": { + "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "signature": "-2474549887-export default MessageablePerson;\n", + "impliedFormat": 1 + }, + "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "signature": "-2474549887-export default MessageablePerson;\n", + "impliedFormat": "commonjs" +} +Clean:: { + "original": { + "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "impliedFormat": 1 + }, + "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "signature": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "impliedFormat": "commonjs" +} +Dts Signature:: $"-21450256696-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n(116,7)Error4094: Property 'message' of exported class expression may not be private or protected." +3:: modify protected to public +*** Needs explanation +TsBuild info text without affectedFilesPendingEmit:: /src/project/tsconfig.tsbuildinfo.readable.baseline.txt:: +CleanBuild: +{ + "program": { + "fileInfos": { + "../../lib/lib.d.ts": { + "version": "5700251342-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };type ReturnType any> = T extends (...args: any) => infer R ? R : any;\ntype InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any;", + "affectsGlobalScope": true, + "impliedFormat": "commonjs" + }, + "./messageableperson.ts": { + "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "impliedFormat": "commonjs" + }, + "./main.ts": { + "version": "4191603667-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}", + "impliedFormat": "commonjs" + } + }, + "root": [ + [ + 2, + "./messageableperson.ts" + ], + [ + 3, + "./main.ts" + ] + ], + "options": { + "declaration": true + }, + "referencedMap": { + "./main.ts": [ + "./messageableperson.ts" + ] + }, + "semanticDiagnosticsPerFile": [ + "../../lib/lib.d.ts", + "./main.ts", + "./messageableperson.ts" + ] + }, + "version": "FakeTSVersion" +} +IncrementalBuild: +{ + "program": { + "fileInfos": { + "../../lib/lib.d.ts": { + "version": "5700251342-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };type ReturnType any> = T extends (...args: any) => infer R ? R : any;\ntype InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any;", + "affectsGlobalScope": true, + "impliedFormat": "commonjs" + }, + "./messageableperson.ts": { + "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "impliedFormat": "commonjs" + }, + "./main.ts": { + "version": "4191603667-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}", + "impliedFormat": "commonjs" + } + }, + "root": [ + [ + 2, + "./messageableperson.ts" + ], + [ + 3, + "./main.ts" + ] + ], + "options": { + "declaration": true + }, + "referencedMap": { + "./main.ts": [ + "./messageableperson.ts" + ] + }, + "semanticDiagnosticsPerFile": [ + "../../lib/lib.d.ts", + [ + "./main.ts", + [ + { + "file": "./main.ts", + "start": 131, + "length": 7, + "messageText": "Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses.", + "category": 1, + "code": 2445 + } + ] + ], + "./messageableperson.ts" + ] + }, + "version": "FakeTSVersion" +} +Incremental signature is neither dts signature nor file version for File:: ./messageableperson.ts +Incremental:: { + "original": { + "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "signature": "-2474549887-export default MessageablePerson;\n", + "impliedFormat": 1 + }, + "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "signature": "-2474549887-export default MessageablePerson;\n", + "impliedFormat": "commonjs" +} +Clean:: { + "original": { + "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "signature": "-21006966954-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n", + "impliedFormat": 1 + }, + "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "signature": "-21006966954-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n", + "impliedFormat": "commonjs" +} +Dts Signature:: $"-21006966954-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n" +4:: no-change-run +*** Needs explanation +TsBuild info text without affectedFilesPendingEmit:: /src/project/tsconfig.tsbuildinfo.readable.baseline.txt:: +CleanBuild: +{ + "program": { + "fileInfos": { + "../../lib/lib.d.ts": { + "version": "5700251342-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };type ReturnType any> = T extends (...args: any) => infer R ? R : any;\ntype InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any;", + "affectsGlobalScope": true, + "impliedFormat": "commonjs" + }, + "./messageableperson.ts": { + "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "impliedFormat": "commonjs" + }, + "./main.ts": { + "version": "4191603667-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}", + "impliedFormat": "commonjs" + } + }, + "root": [ + [ + 2, + "./messageableperson.ts" + ], + [ + 3, + "./main.ts" + ] + ], + "options": { + "declaration": true + }, + "referencedMap": { + "./main.ts": [ + "./messageableperson.ts" + ] + }, + "semanticDiagnosticsPerFile": [ + "../../lib/lib.d.ts", + "./main.ts", + "./messageableperson.ts" + ] + }, + "version": "FakeTSVersion" +} +IncrementalBuild: +{ + "program": { + "fileInfos": { + "../../lib/lib.d.ts": { + "version": "5700251342-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };type ReturnType any> = T extends (...args: any) => infer R ? R : any;\ntype InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any;", + "affectsGlobalScope": true, + "impliedFormat": "commonjs" + }, + "./messageableperson.ts": { + "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "impliedFormat": "commonjs" + }, + "./main.ts": { + "version": "4191603667-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}", + "impliedFormat": "commonjs" + } + }, + "root": [ + [ + 2, + "./messageableperson.ts" + ], + [ + 3, + "./main.ts" + ] + ], + "options": { + "declaration": true + }, + "referencedMap": { + "./main.ts": [ + "./messageableperson.ts" + ] + }, + "semanticDiagnosticsPerFile": [ + "../../lib/lib.d.ts", + [ + "./main.ts", + [ + { + "file": "./main.ts", + "start": 131, + "length": 7, + "messageText": "Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses.", + "category": 1, + "code": 2445 + } + ] + ], + "./messageableperson.ts" + ] + }, + "version": "FakeTSVersion" +} +Incremental signature is neither dts signature nor file version for File:: ./messageableperson.ts +Incremental:: { + "original": { + "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "signature": "-2474549887-export default MessageablePerson;\n", + "impliedFormat": 1 + }, + "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "signature": "-2474549887-export default MessageablePerson;\n", + "impliedFormat": "commonjs" +} +Clean:: { + "original": { + "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "signature": "-21006966954-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n", + "impliedFormat": 1 + }, + "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", + "signature": "-21006966954-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n", + "impliedFormat": "commonjs" +} +Dts Signature:: $"-21006966954-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n" \ No newline at end of file diff --git a/tests/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled.js b/tests/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled.js index c1b0eea3b9eff..9c27d4a58d2b3 100644 --- a/tests/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled.js +++ b/tests/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled.js @@ -211,7 +211,7 @@ exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped //// [/src/project/main.js] file written with same contents //// [/src/project/MessageablePerson.js] file written with same contents //// [/src/project/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.d.ts","./messageableperson.ts","./main.ts"],"fileInfos":[{"version":"5700251342-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };type ReturnType any> = T extends (...args: any) => infer R ? R : any;\ntype InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any;","affectsGlobalScope":true,"impliedFormat":1},{"version":"3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;","signature":"-21450256696-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n(116,7)Error4094: Property 'message' of exported class expression may not be private or protected.","impliedFormat":1},{"version":"4191603667-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}","signature":"-3531856636-export {};\n","impliedFormat":1}],"root":[2,3],"options":{"declaration":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"semanticDiagnosticsPerFile":[1,[3,[{"file":"./main.ts","start":131,"length":7,"messageText":"Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses.","category":1,"code":2445}]],2],"emitDiagnosticsPerFile":[[2,[{"file":"./messageableperson.ts","start":116,"length":7,"messageText":"Property 'message' of exported class expression may not be private or protected.","category":1,"code":4094}]]]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../lib/lib.d.ts","./messageableperson.ts","./main.ts"],"fileInfos":[{"version":"5700251342-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };type ReturnType any> = T extends (...args: any) => infer R ? R : any;\ntype InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any;","affectsGlobalScope":true,"impliedFormat":1},{"version":"3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;","signature":"-2474549887-export default MessageablePerson;\n","impliedFormat":1},{"version":"4191603667-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}","signature":"-3531856636-export {};\n","impliedFormat":1}],"root":[2,3],"options":{"declaration":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"semanticDiagnosticsPerFile":[1,[3,[{"file":"./main.ts","start":131,"length":7,"messageText":"Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses.","category":1,"code":2445}]],2],"emitDiagnosticsPerFile":[[2,[{"file":"./messageableperson.ts","start":116,"length":7,"messageText":"Property 'message' of exported class expression may not be private or protected.","category":1,"code":4094}]]]},"version":"FakeTSVersion"} //// [/src/project/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -241,11 +241,11 @@ exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped "./messageableperson.ts": { "original": { "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-21450256696-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n(116,7)Error4094: Property 'message' of exported class expression may not be private or protected.", + "signature": "-2474549887-export default MessageablePerson;\n", "impliedFormat": 1 }, "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-21450256696-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n(116,7)Error4094: Property 'message' of exported class expression may not be private or protected.", + "signature": "-2474549887-export default MessageablePerson;\n", "impliedFormat": "commonjs" }, "./main.ts": { @@ -311,7 +311,7 @@ exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped ] }, "version": "FakeTSVersion", - "size": 2217 + "size": 1965 } @@ -359,15 +359,21 @@ export default MessageablePerson; Output:: /lib/tsc -p src/project --incremental -exitCode:: ExitStatus.Success +src/project/main.ts:3:25 - error TS2445: Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses. + +3 console.log( person.message ); +   ~~~~~~~ + + +Found 1 error in src/project/main.ts:3 + +exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated -//// [/src/project/main.d.ts] file written with same contents -//// [/src/project/main.js] file written with same contents //// [/src/project/MessageablePerson.d.ts] file written with same contents //// [/src/project/MessageablePerson.js] file written with same contents //// [/src/project/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.d.ts","./messageableperson.ts","./main.ts"],"fileInfos":[{"version":"5700251342-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };type ReturnType any> = T extends (...args: any) => infer R ? R : any;\ntype InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any;","affectsGlobalScope":true,"impliedFormat":1},{"version":"31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;","signature":"-21006966954-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n","impliedFormat":1},{"version":"4191603667-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}","signature":"-3531856636-export {};\n","impliedFormat":1}],"root":[2,3],"options":{"declaration":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"semanticDiagnosticsPerFile":[1,3,2]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../lib/lib.d.ts","./messageableperson.ts","./main.ts"],"fileInfos":[{"version":"5700251342-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };type ReturnType any> = T extends (...args: any) => infer R ? R : any;\ntype InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any;","affectsGlobalScope":true,"impliedFormat":1},{"version":"31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;","signature":"-2474549887-export default MessageablePerson;\n","impliedFormat":1},{"version":"4191603667-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}","signature":"-3531856636-export {};\n","impliedFormat":1}],"root":[2,3],"options":{"declaration":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"semanticDiagnosticsPerFile":[1,[3,[{"file":"./main.ts","start":131,"length":7,"messageText":"Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses.","category":1,"code":2445}]],2]},"version":"FakeTSVersion"} //// [/src/project/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -397,11 +403,11 @@ exitCode:: ExitStatus.Success "./messageableperson.ts": { "original": { "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-21006966954-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n", + "signature": "-2474549887-export default MessageablePerson;\n", "impliedFormat": 1 }, "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-21006966954-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n", + "signature": "-2474549887-export default MessageablePerson;\n", "impliedFormat": "commonjs" }, "./main.ts": { @@ -435,12 +441,24 @@ exitCode:: ExitStatus.Success }, "semanticDiagnosticsPerFile": [ "../../lib/lib.d.ts", - "./main.ts", + [ + "./main.ts", + [ + { + "file": "./main.ts", + "start": 131, + "length": 7, + "messageText": "Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses.", + "category": 1, + "code": 2445 + } + ] + ], "./messageableperson.ts" ] }, "version": "FakeTSVersion", - "size": 1712 + "size": 1751 } @@ -451,6 +469,14 @@ Input:: Output:: /lib/tsc -p src/project --incremental -exitCode:: ExitStatus.Success +src/project/main.ts:3:25 - error TS2445: Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses. + +3 console.log( person.message ); +   ~~~~~~~ + + +Found 1 error in src/project/main.ts:3 + +exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated From 23f72040c975fe3b60173794d7d646c5b06b3822 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 20 May 2024 14:05:12 -0700 Subject: [PATCH 3/7] Collect aliases --- src/compiler/emitter.ts | 2 +- .../demo/updates-with-bad-reference.js | 8 +- ...-declaration-emit-enabled-discrepancies.js | 296 ------------------ ...ion-field-with-declaration-emit-enabled.js | 52 +-- 4 files changed, 18 insertions(+), 340 deletions(-) delete mode 100644 tests/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled-discrepancies.js diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 03fe0e5e3859e..5934a4358d6bd 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -848,7 +848,7 @@ export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFi const filesForEmit = forceDtsEmit ? sourceFiles : filter(sourceFiles, isSourceFileNotJson); // Setup and perform the transformation to retrieve declarations from the input files const inputListOrBundle = compilerOptions.outFile ? [factory.createBundle(filesForEmit)] : filesForEmit; - if ((emitOnly && !getEmitDeclarations(compilerOptions)) || compilerOptions.noCheck) { + if ((emitOnly && !getEmitDeclarations(compilerOptions)) || compilerOptions.noCheck || forceDtsEmit) { // Checker wont collect the linked aliases since thats only done when declaration is enabled and checking is performed. // Do that here when emitting only dts files filesForEmit.forEach(collectLinkedAliases); diff --git a/tests/baselines/reference/tsbuildWatch/demo/updates-with-bad-reference.js b/tests/baselines/reference/tsbuildWatch/demo/updates-with-bad-reference.js index 49c578d2146b6..42f6c2e900831 100644 --- a/tests/baselines/reference/tsbuildWatch/demo/updates-with-bad-reference.js +++ b/tests/baselines/reference/tsbuildWatch/demo/updates-with-bad-reference.js @@ -556,7 +556,7 @@ Output:: //// [/user/username/projects/demo/lib/core/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../../../../a/lib/lib.d.ts","../../animals/animal.ts","../../animals/dog.ts","../../animals/index.ts","../../core/utilities.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedFormat":1},{"version":"-9289341318-export type Size = \"small\" | \"medium\" | \"large\";\nexport default interface Animal {\n size: Size;\n}\n","impliedFormat":1},{"version":"-18870194049-import Animal from '.';\nimport { makeRandomName } from '../core/utilities';\n\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\n\nexport function createDog(): Dog {\n return ({\n size: \"medium\",\n woof: function(this: Dog) {\n console.log(`${ this.name } says \"Woof\"!`);\n },\n name: makeRandomName()\n });\n}\n","signature":"6032048049-import Animal from '.';\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\nexport declare function createDog(): Dog;\n","impliedFormat":1},{"version":"-7220553464-import Animal from './animal';\n\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n","signature":"2198076214-export default Animal;\nexport { createDog, Dog };\n","impliedFormat":1},{"version":"-11321611519-\nimport * as A from '../animals';\nexport function makeRandomName() {\n return \"Bob!?! \";\n}\n\nexport function lastElementOf(arr: T[]): T | undefined {\n if (arr.length === 0) return undefined;\n return arr[arr.length - 1];\n}\n","signature":"-11345568166-export declare function makeRandomName(): string;\nexport declare function lastElementOf(arr: T[]): T | undefined;\n","impliedFormat":1}],"root":[5],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../core","strict":true,"target":1},"fileIdsList":[[4,5],[2,3],[4]],"referencedMap":[[3,1],[4,2],[5,3]],"semanticDiagnosticsPerFile":[1,2,3,4,[5,[{"file":"../../core/utilities.ts","start":1,"length":32,"messageText":"'A' is declared but its value is never read.","category":1,"code":6133,"reportsUnnecessary":true}]]],"affectedFilesPendingEmit":[2,3,4,5],"emitSignatures":[2,3,4,5]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../../../../a/lib/lib.d.ts","../../animals/animal.ts","../../animals/dog.ts","../../animals/index.ts","../../core/utilities.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedFormat":1},{"version":"-9289341318-export type Size = \"small\" | \"medium\" | \"large\";\nexport default interface Animal {\n size: Size;\n}\n","impliedFormat":1},{"version":"-18870194049-import Animal from '.';\nimport { makeRandomName } from '../core/utilities';\n\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\n\nexport function createDog(): Dog {\n return ({\n size: \"medium\",\n woof: function(this: Dog) {\n console.log(`${ this.name } says \"Woof\"!`);\n },\n name: makeRandomName()\n });\n}\n","signature":"6032048049-import Animal from '.';\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\nexport declare function createDog(): Dog;\n","impliedFormat":1},{"version":"-7220553464-import Animal from './animal';\n\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n","signature":"1096904574-import Animal from './animal';\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n","impliedFormat":1},{"version":"-11321611519-\nimport * as A from '../animals';\nexport function makeRandomName() {\n return \"Bob!?! \";\n}\n\nexport function lastElementOf(arr: T[]): T | undefined {\n if (arr.length === 0) return undefined;\n return arr[arr.length - 1];\n}\n","signature":"-11345568166-export declare function makeRandomName(): string;\nexport declare function lastElementOf(arr: T[]): T | undefined;\n","impliedFormat":1}],"root":[5],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../core","strict":true,"target":1},"fileIdsList":[[4,5],[2,3],[4]],"referencedMap":[[3,1],[4,2],[5,3]],"semanticDiagnosticsPerFile":[1,2,3,4,[5,[{"file":"../../core/utilities.ts","start":1,"length":32,"messageText":"'A' is declared but its value is never read.","category":1,"code":6133,"reportsUnnecessary":true}]]],"affectedFilesPendingEmit":[2,3,4,5],"emitSignatures":[2,3,4,5]},"version":"FakeTSVersion"} //// [/user/username/projects/demo/lib/core/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -615,11 +615,11 @@ Output:: "../../animals/index.ts": { "original": { "version": "-7220553464-import Animal from './animal';\n\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n", - "signature": "2198076214-export default Animal;\nexport { createDog, Dog };\n", + "signature": "1096904574-import Animal from './animal';\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n", "impliedFormat": 1 }, "version": "-7220553464-import Animal from './animal';\n\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n", - "signature": "2198076214-export default Animal;\nexport { createDog, Dog };\n", + "signature": "1096904574-import Animal from './animal';\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n", "impliedFormat": "commonjs" }, "../../core/utilities.ts": { @@ -711,7 +711,7 @@ Output:: ] }, "version": "FakeTSVersion", - "size": 2739 + "size": 2812 } diff --git a/tests/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled-discrepancies.js b/tests/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled-discrepancies.js deleted file mode 100644 index b1c50c83719ac..0000000000000 --- a/tests/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled-discrepancies.js +++ /dev/null @@ -1,296 +0,0 @@ -1:: modify public to protected -*** Needs explanation -Incremental signature is neither dts signature nor file version for File:: ./messageableperson.ts -Incremental:: { - "original": { - "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-2474549887-export default MessageablePerson;\n", - "impliedFormat": 1 - }, - "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-2474549887-export default MessageablePerson;\n", - "impliedFormat": "commonjs" -} -Clean:: { - "original": { - "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "impliedFormat": 1 - }, - "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "impliedFormat": "commonjs" -} -Dts Signature:: $"-21450256696-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n(116,7)Error4094: Property 'message' of exported class expression may not be private or protected." -2:: no-change-run -*** Needs explanation -Incremental signature is neither dts signature nor file version for File:: ./messageableperson.ts -Incremental:: { - "original": { - "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-2474549887-export default MessageablePerson;\n", - "impliedFormat": 1 - }, - "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-2474549887-export default MessageablePerson;\n", - "impliedFormat": "commonjs" -} -Clean:: { - "original": { - "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "impliedFormat": 1 - }, - "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "impliedFormat": "commonjs" -} -Dts Signature:: $"-21450256696-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n(116,7)Error4094: Property 'message' of exported class expression may not be private or protected." -3:: modify protected to public -*** Needs explanation -TsBuild info text without affectedFilesPendingEmit:: /src/project/tsconfig.tsbuildinfo.readable.baseline.txt:: -CleanBuild: -{ - "program": { - "fileInfos": { - "../../lib/lib.d.ts": { - "version": "5700251342-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };type ReturnType any> = T extends (...args: any) => infer R ? R : any;\ntype InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any;", - "affectsGlobalScope": true, - "impliedFormat": "commonjs" - }, - "./messageableperson.ts": { - "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "impliedFormat": "commonjs" - }, - "./main.ts": { - "version": "4191603667-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}", - "impliedFormat": "commonjs" - } - }, - "root": [ - [ - 2, - "./messageableperson.ts" - ], - [ - 3, - "./main.ts" - ] - ], - "options": { - "declaration": true - }, - "referencedMap": { - "./main.ts": [ - "./messageableperson.ts" - ] - }, - "semanticDiagnosticsPerFile": [ - "../../lib/lib.d.ts", - "./main.ts", - "./messageableperson.ts" - ] - }, - "version": "FakeTSVersion" -} -IncrementalBuild: -{ - "program": { - "fileInfos": { - "../../lib/lib.d.ts": { - "version": "5700251342-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };type ReturnType any> = T extends (...args: any) => infer R ? R : any;\ntype InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any;", - "affectsGlobalScope": true, - "impliedFormat": "commonjs" - }, - "./messageableperson.ts": { - "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "impliedFormat": "commonjs" - }, - "./main.ts": { - "version": "4191603667-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}", - "impliedFormat": "commonjs" - } - }, - "root": [ - [ - 2, - "./messageableperson.ts" - ], - [ - 3, - "./main.ts" - ] - ], - "options": { - "declaration": true - }, - "referencedMap": { - "./main.ts": [ - "./messageableperson.ts" - ] - }, - "semanticDiagnosticsPerFile": [ - "../../lib/lib.d.ts", - [ - "./main.ts", - [ - { - "file": "./main.ts", - "start": 131, - "length": 7, - "messageText": "Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses.", - "category": 1, - "code": 2445 - } - ] - ], - "./messageableperson.ts" - ] - }, - "version": "FakeTSVersion" -} -Incremental signature is neither dts signature nor file version for File:: ./messageableperson.ts -Incremental:: { - "original": { - "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-2474549887-export default MessageablePerson;\n", - "impliedFormat": 1 - }, - "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-2474549887-export default MessageablePerson;\n", - "impliedFormat": "commonjs" -} -Clean:: { - "original": { - "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-21006966954-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n", - "impliedFormat": 1 - }, - "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-21006966954-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n", - "impliedFormat": "commonjs" -} -Dts Signature:: $"-21006966954-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n" -4:: no-change-run -*** Needs explanation -TsBuild info text without affectedFilesPendingEmit:: /src/project/tsconfig.tsbuildinfo.readable.baseline.txt:: -CleanBuild: -{ - "program": { - "fileInfos": { - "../../lib/lib.d.ts": { - "version": "5700251342-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };type ReturnType any> = T extends (...args: any) => infer R ? R : any;\ntype InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any;", - "affectsGlobalScope": true, - "impliedFormat": "commonjs" - }, - "./messageableperson.ts": { - "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "impliedFormat": "commonjs" - }, - "./main.ts": { - "version": "4191603667-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}", - "impliedFormat": "commonjs" - } - }, - "root": [ - [ - 2, - "./messageableperson.ts" - ], - [ - 3, - "./main.ts" - ] - ], - "options": { - "declaration": true - }, - "referencedMap": { - "./main.ts": [ - "./messageableperson.ts" - ] - }, - "semanticDiagnosticsPerFile": [ - "../../lib/lib.d.ts", - "./main.ts", - "./messageableperson.ts" - ] - }, - "version": "FakeTSVersion" -} -IncrementalBuild: -{ - "program": { - "fileInfos": { - "../../lib/lib.d.ts": { - "version": "5700251342-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };type ReturnType any> = T extends (...args: any) => infer R ? R : any;\ntype InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any;", - "affectsGlobalScope": true, - "impliedFormat": "commonjs" - }, - "./messageableperson.ts": { - "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "impliedFormat": "commonjs" - }, - "./main.ts": { - "version": "4191603667-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}", - "impliedFormat": "commonjs" - } - }, - "root": [ - [ - 2, - "./messageableperson.ts" - ], - [ - 3, - "./main.ts" - ] - ], - "options": { - "declaration": true - }, - "referencedMap": { - "./main.ts": [ - "./messageableperson.ts" - ] - }, - "semanticDiagnosticsPerFile": [ - "../../lib/lib.d.ts", - [ - "./main.ts", - [ - { - "file": "./main.ts", - "start": 131, - "length": 7, - "messageText": "Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses.", - "category": 1, - "code": 2445 - } - ] - ], - "./messageableperson.ts" - ] - }, - "version": "FakeTSVersion" -} -Incremental signature is neither dts signature nor file version for File:: ./messageableperson.ts -Incremental:: { - "original": { - "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-2474549887-export default MessageablePerson;\n", - "impliedFormat": 1 - }, - "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-2474549887-export default MessageablePerson;\n", - "impliedFormat": "commonjs" -} -Clean:: { - "original": { - "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-21006966954-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n", - "impliedFormat": 1 - }, - "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-21006966954-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n", - "impliedFormat": "commonjs" -} -Dts Signature:: $"-21006966954-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n" \ No newline at end of file diff --git a/tests/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled.js b/tests/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled.js index 9c27d4a58d2b3..c1b0eea3b9eff 100644 --- a/tests/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled.js +++ b/tests/baselines/reference/tsc/incremental/change-to-modifier-of-class-expression-field-with-declaration-emit-enabled.js @@ -211,7 +211,7 @@ exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped //// [/src/project/main.js] file written with same contents //// [/src/project/MessageablePerson.js] file written with same contents //// [/src/project/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.d.ts","./messageableperson.ts","./main.ts"],"fileInfos":[{"version":"5700251342-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };type ReturnType any> = T extends (...args: any) => infer R ? R : any;\ntype InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any;","affectsGlobalScope":true,"impliedFormat":1},{"version":"3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;","signature":"-2474549887-export default MessageablePerson;\n","impliedFormat":1},{"version":"4191603667-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}","signature":"-3531856636-export {};\n","impliedFormat":1}],"root":[2,3],"options":{"declaration":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"semanticDiagnosticsPerFile":[1,[3,[{"file":"./main.ts","start":131,"length":7,"messageText":"Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses.","category":1,"code":2445}]],2],"emitDiagnosticsPerFile":[[2,[{"file":"./messageableperson.ts","start":116,"length":7,"messageText":"Property 'message' of exported class expression may not be private or protected.","category":1,"code":4094}]]]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../lib/lib.d.ts","./messageableperson.ts","./main.ts"],"fileInfos":[{"version":"5700251342-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };type ReturnType any> = T extends (...args: any) => infer R ? R : any;\ntype InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any;","affectsGlobalScope":true,"impliedFormat":1},{"version":"3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;","signature":"-21450256696-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n(116,7)Error4094: Property 'message' of exported class expression may not be private or protected.","impliedFormat":1},{"version":"4191603667-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}","signature":"-3531856636-export {};\n","impliedFormat":1}],"root":[2,3],"options":{"declaration":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"semanticDiagnosticsPerFile":[1,[3,[{"file":"./main.ts","start":131,"length":7,"messageText":"Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses.","category":1,"code":2445}]],2],"emitDiagnosticsPerFile":[[2,[{"file":"./messageableperson.ts","start":116,"length":7,"messageText":"Property 'message' of exported class expression may not be private or protected.","category":1,"code":4094}]]]},"version":"FakeTSVersion"} //// [/src/project/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -241,11 +241,11 @@ exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped "./messageableperson.ts": { "original": { "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-2474549887-export default MessageablePerson;\n", + "signature": "-21450256696-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n(116,7)Error4094: Property 'message' of exported class expression may not be private or protected.", "impliedFormat": 1 }, "version": "3462418372-const Messageable = () => {\n return class MessageableClass {\n protected message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-2474549887-export default MessageablePerson;\n", + "signature": "-21450256696-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n(116,7)Error4094: Property 'message' of exported class expression may not be private or protected.", "impliedFormat": "commonjs" }, "./main.ts": { @@ -311,7 +311,7 @@ exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped ] }, "version": "FakeTSVersion", - "size": 1965 + "size": 2217 } @@ -359,21 +359,15 @@ export default MessageablePerson; Output:: /lib/tsc -p src/project --incremental -src/project/main.ts:3:25 - error TS2445: Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses. - -3 console.log( person.message ); -   ~~~~~~~ - - -Found 1 error in src/project/main.ts:3 - -exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated +exitCode:: ExitStatus.Success +//// [/src/project/main.d.ts] file written with same contents +//// [/src/project/main.js] file written with same contents //// [/src/project/MessageablePerson.d.ts] file written with same contents //// [/src/project/MessageablePerson.js] file written with same contents //// [/src/project/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.d.ts","./messageableperson.ts","./main.ts"],"fileInfos":[{"version":"5700251342-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };type ReturnType any> = T extends (...args: any) => infer R ? R : any;\ntype InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any;","affectsGlobalScope":true,"impliedFormat":1},{"version":"31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;","signature":"-2474549887-export default MessageablePerson;\n","impliedFormat":1},{"version":"4191603667-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}","signature":"-3531856636-export {};\n","impliedFormat":1}],"root":[2,3],"options":{"declaration":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"semanticDiagnosticsPerFile":[1,[3,[{"file":"./main.ts","start":131,"length":7,"messageText":"Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses.","category":1,"code":2445}]],2]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../lib/lib.d.ts","./messageableperson.ts","./main.ts"],"fileInfos":[{"version":"5700251342-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };type ReturnType any> = T extends (...args: any) => infer R ? R : any;\ntype InstanceType any> = T extends abstract new (...args: any) => infer R ? R : any;","affectsGlobalScope":true,"impliedFormat":1},{"version":"31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;","signature":"-21006966954-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n","impliedFormat":1},{"version":"4191603667-import MessageablePerson from './MessageablePerson.js';\nfunction logMessage( person: MessageablePerson ) {\n console.log( person.message );\n}","signature":"-3531856636-export {};\n","impliedFormat":1}],"root":[2,3],"options":{"declaration":true},"fileIdsList":[[2]],"referencedMap":[[3,1]],"semanticDiagnosticsPerFile":[1,3,2]},"version":"FakeTSVersion"} //// [/src/project/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -403,11 +397,11 @@ exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated "./messageableperson.ts": { "original": { "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-2474549887-export default MessageablePerson;\n", + "signature": "-21006966954-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n", "impliedFormat": 1 }, "version": "31173349369-const Messageable = () => {\n return class MessageableClass {\n public message = 'hello';\n }\n};\nconst wrapper = () => Messageable();\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;", - "signature": "-2474549887-export default MessageablePerson;\n", + "signature": "-21006966954-declare const wrapper: () => {\n new (): {\n message: string;\n };\n};\ntype MessageablePerson = InstanceType>;\nexport default MessageablePerson;\n", "impliedFormat": "commonjs" }, "./main.ts": { @@ -441,24 +435,12 @@ exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated }, "semanticDiagnosticsPerFile": [ "../../lib/lib.d.ts", - [ - "./main.ts", - [ - { - "file": "./main.ts", - "start": 131, - "length": 7, - "messageText": "Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses.", - "category": 1, - "code": 2445 - } - ] - ], + "./main.ts", "./messageableperson.ts" ] }, "version": "FakeTSVersion", - "size": 1751 + "size": 1712 } @@ -469,14 +451,6 @@ Input:: Output:: /lib/tsc -p src/project --incremental -src/project/main.ts:3:25 - error TS2445: Property 'message' is protected and only accessible within class 'MessageableClass' and its subclasses. - -3 console.log( person.message ); -   ~~~~~~~ - - -Found 1 error in src/project/main.ts:3 - -exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated +exitCode:: ExitStatus.Success From d9fce93c032e1487ac201654e0d05d21d378c343 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 20 May 2024 15:18:15 -0700 Subject: [PATCH 4/7] Emit with cancellation token enabled esp now that declaration emit can resolve types etc without type checking --- src/compiler/program.ts | 27 +++-- src/compiler/types.ts | 2 + .../unittests/tsc/cancellationToken.ts | 6 +- .../when-emitting-buildInfo.js | 110 ++++++++---------- .../tsc/cancellationToken/when-using-state.js | 110 ++++++++---------- 5 files changed, 121 insertions(+), 134 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 39fb1b7ea338e..6b5ad01ed9da1 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2870,18 +2870,27 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg // This is because in the -out scenario all files need to be emitted, and therefore all // files need to be type checked. And the way to specify that all files need to be type // checked is to not pass the file to getEmitResolver. - const emitResolver = getTypeChecker().getEmitResolver(options.outFile ? undefined : sourceFile, cancellationToken, forceDtsEmit); + const typeChecker = getTypeChecker(); + const emitResolver = typeChecker.getEmitResolver( + options.outFile ? undefined : sourceFile, + cancellationToken, + forceDtsEmit, + ); performance.mark("beforeEmit"); - const emitResult = emitFiles( - emitResolver, - getEmitHost(writeFileCallback), - sourceFile, - getTransformers(options, customTransformers, emitOnly), - emitOnly, - /*onlyBuildInfo*/ false, - forceDtsEmit, + const emitResult = typeChecker.runWithCancellationToken( + cancellationToken, + () => + emitFiles( + emitResolver, + getEmitHost(writeFileCallback), + sourceFile, + getTransformers(options, customTransformers, emitOnly), + emitOnly, + /*onlyBuildInfo*/ false, + forceDtsEmit, + ), ); performance.mark("afterEmit"); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 198bb33fa9902..5dea8bb4d047a 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -5354,6 +5354,8 @@ export interface TypeChecker { * and the operation is cancelled, then it should be discarded, otherwise it is safe to keep. */ runWithCancellationToken(token: CancellationToken, cb: (checker: TypeChecker) => T): T; + /**@internal */ + runWithCancellationToken(token: CancellationToken | undefined, cb: (checker: TypeChecker) => T): T; // eslint-disable-line @typescript-eslint/unified-signatures /** @internal */ getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol: Symbol): readonly TypeParameter[] | undefined; /** @internal */ isDeclarationVisible(node: Declaration | AnyImportSyntax): boolean; diff --git a/src/testRunner/unittests/tsc/cancellationToken.ts b/src/testRunner/unittests/tsc/cancellationToken.ts index e66a2a51ab772..1570680b63fd1 100644 --- a/src/testRunner/unittests/tsc/cancellationToken.ts +++ b/src/testRunner/unittests/tsc/cancellationToken.ts @@ -17,7 +17,7 @@ import { libFile, } from "../helpers/virtualFileSystemWithWatch.js"; -describe("unittests:: tsc:: builder cancellationToken", () => { +describe("unittests:: tsc:: builder cancellationToken:: sheetal", () => { verifyCancellation(/*useBuildInfo*/ true, "when emitting buildInfo"); verifyCancellation(/*useBuildInfo*/ false, "when using state"); function verifyCancellation(useBuildInfo: boolean, scenario: string) { @@ -41,9 +41,9 @@ describe("unittests:: tsc:: builder cancellationToken", () => { const cFile: File = { path: `/user/username/projects/myproject/c.ts`, content: Utils.dedent` - export class C { + export var C = class CReal { d = 1; - }`, + };`, }; const dFile: File = { path: `/user/username/projects/myproject/d.ts`, diff --git a/tests/baselines/reference/tsc/cancellationToken/when-emitting-buildInfo.js b/tests/baselines/reference/tsc/cancellationToken/when-emitting-buildInfo.js index b6dff17c055ef..028c4b56a0894 100644 --- a/tests/baselines/reference/tsc/cancellationToken/when-emitting-buildInfo.js +++ b/tests/baselines/reference/tsc/cancellationToken/when-emitting-buildInfo.js @@ -13,9 +13,9 @@ export class B { } //// [/user/username/projects/myproject/c.ts] -export class C { +export var C = class CReal { d = 1; -} +}; //// [/user/username/projects/myproject/d.ts] export class D { } @@ -46,19 +46,20 @@ interface Array { length: number; [n: number]: T; } "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.C = void 0; -var C = /** @class */ (function () { - function C() { +exports.C = /** @class */ (function () { + function CReal() { this.d = 1; } - return C; + return CReal; }()); -exports.C = C; //// [/user/username/projects/myproject/c.d.ts] -export declare class C { - d: number; -} +export declare var C: { + new (): { + d: number; + }; +}; //// [/user/username/projects/myproject/b.js] @@ -76,9 +77,10 @@ exports.B = B; //// [/user/username/projects/myproject/b.d.ts] -import { C } from './c'; export declare class B { - c: C; + c: { + d: number; + }; } @@ -112,7 +114,7 @@ export declare class D { //// [/user/username/projects/myproject/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./c.ts","./b.ts","./a.ts","./d.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"-5130721255-export class C {\n d = 1;\n}","signature":"-6977846840-export declare class C {\n d: number;\n}\n","impliedFormat":1},{"version":"-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}","signature":"-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n","impliedFormat":1},{"version":"4878398349-import {B} from './b';\ndeclare var console: any;\nlet b = new B();\nconsole.log(b.c.d);","signature":"-3531856636-export {};\n","impliedFormat":1},{"version":"-7804761415-export class D { }","signature":"-8611429667-export declare class D {\n}\n","impliedFormat":1}],"root":[[2,5]],"options":{"declaration":true},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,4,3,2,5]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./c.ts","./b.ts","./a.ts","./d.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"6071811233-export var C = class CReal {\n d = 1;\n};","signature":"-2874569268-export declare var C: {\n new (): {\n d: number;\n };\n};\n","impliedFormat":1},{"version":"-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}","signature":"-12916012021-export declare class B {\n c: {\n d: number;\n };\n}\n","impliedFormat":1},{"version":"4878398349-import {B} from './b';\ndeclare var console: any;\nlet b = new B();\nconsole.log(b.c.d);","signature":"-3531856636-export {};\n","impliedFormat":1},{"version":"-7804761415-export class D { }","signature":"-8611429667-export declare class D {\n}\n","impliedFormat":1}],"root":[[2,5]],"options":{"declaration":true},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,4,3,2,5]},"version":"FakeTSVersion"} //// [/user/username/projects/myproject/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -146,22 +148,22 @@ export declare class D { }, "./c.ts": { "original": { - "version": "-5130721255-export class C {\n d = 1;\n}", - "signature": "-6977846840-export declare class C {\n d: number;\n}\n", + "version": "6071811233-export var C = class CReal {\n d = 1;\n};", + "signature": "-2874569268-export declare var C: {\n new (): {\n d: number;\n };\n};\n", "impliedFormat": 1 }, - "version": "-5130721255-export class C {\n d = 1;\n}", - "signature": "-6977846840-export declare class C {\n d: number;\n}\n", + "version": "6071811233-export var C = class CReal {\n d = 1;\n};", + "signature": "-2874569268-export declare var C: {\n new (): {\n d: number;\n };\n};\n", "impliedFormat": "commonjs" }, "./b.ts": { "original": { "version": "-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}", - "signature": "-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n", + "signature": "-12916012021-export declare class B {\n c: {\n d: number;\n };\n}\n", "impliedFormat": 1 }, "version": "-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}", - "signature": "-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n", + "signature": "-12916012021-export declare class B {\n c: {\n d: number;\n };\n}\n", "impliedFormat": "commonjs" }, "./a.ts": { @@ -219,7 +221,7 @@ export declare class D { ] }, "version": "FakeTSVersion", - "size": 1326 + "size": 1368 } @@ -262,9 +264,9 @@ Change:: Add change that affects d.ts Input:: //// [/user/username/projects/myproject/c.ts] -export class C { +export var C = class CReal { d = 1; -}export function foo() {} +};export function foo() {} Output:: @@ -273,7 +275,7 @@ Operation ws cancelled:: true //// [/user/username/projects/myproject/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./c.ts","./b.ts","./a.ts","./d.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"840271342-export class C {\n d = 1;\n}export function foo() {}","signature":"-6977846840-export declare class C {\n d: number;\n}\n","impliedFormat":1},{"version":"-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}","signature":"-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n","impliedFormat":1},{"version":"4878398349-import {B} from './b';\ndeclare var console: any;\nlet b = new B();\nconsole.log(b.c.d);","signature":"-3531856636-export {};\n","impliedFormat":1},{"version":"-7804761415-export class D { }","signature":"-8611429667-export declare class D {\n}\n","impliedFormat":1}],"root":[[2,5]],"options":{"declaration":true},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,3,5],"affectedFilesPendingEmit":[[4],2],"changeFileSet":[2]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./c.ts","./b.ts","./a.ts","./d.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"-8116587914-export var C = class CReal {\n d = 1;\n};export function foo() {}","signature":"-2874569268-export declare var C: {\n new (): {\n d: number;\n };\n};\n","impliedFormat":1},{"version":"-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}","signature":"-12916012021-export declare class B {\n c: {\n d: number;\n };\n}\n","impliedFormat":1},{"version":"4878398349-import {B} from './b';\ndeclare var console: any;\nlet b = new B();\nconsole.log(b.c.d);","signature":"-3531856636-export {};\n","impliedFormat":1},{"version":"-7804761415-export class D { }","signature":"-8611429667-export declare class D {\n}\n","impliedFormat":1}],"root":[[2,5]],"options":{"declaration":true},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,4,3,5],"changeFileSet":[2]},"version":"FakeTSVersion"} //// [/user/username/projects/myproject/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -307,22 +309,22 @@ Operation ws cancelled:: true }, "./c.ts": { "original": { - "version": "840271342-export class C {\n d = 1;\n}export function foo() {}", - "signature": "-6977846840-export declare class C {\n d: number;\n}\n", + "version": "-8116587914-export var C = class CReal {\n d = 1;\n};export function foo() {}", + "signature": "-2874569268-export declare var C: {\n new (): {\n d: number;\n };\n};\n", "impliedFormat": 1 }, - "version": "840271342-export class C {\n d = 1;\n}export function foo() {}", - "signature": "-6977846840-export declare class C {\n d: number;\n}\n", + "version": "-8116587914-export var C = class CReal {\n d = 1;\n};export function foo() {}", + "signature": "-2874569268-export declare var C: {\n new (): {\n d: number;\n };\n};\n", "impliedFormat": "commonjs" }, "./b.ts": { "original": { "version": "-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}", - "signature": "-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n", + "signature": "-12916012021-export declare class B {\n c: {\n d: number;\n };\n}\n", "impliedFormat": 1 }, "version": "-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}", - "signature": "-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n", + "signature": "-12916012021-export declare class B {\n c: {\n d: number;\n };\n}\n", "impliedFormat": "commonjs" }, "./a.ts": { @@ -373,27 +375,16 @@ Operation ws cancelled:: true }, "semanticDiagnosticsPerFile": [ "../../../../a/lib/lib.d.ts", + "./a.ts", "./b.ts", "./d.ts" ], - "affectedFilesPendingEmit": [ - [ - [ - "./a.ts" - ], - "Dts" - ], - [ - "./c.ts", - "Js | Dts" - ] - ], "changeFileSet": [ "./c.ts" ] }, "version": "FakeTSVersion", - "size": 1399 + "size": 1411 } @@ -418,12 +409,8 @@ Program files:: Semantic diagnostics in builder refreshed for:: /user/username/projects/myproject/c.ts -/user/username/projects/myproject/a.ts -Shape signatures in builder refreshed for:: -/user/username/projects/myproject/c.ts (computed .d.ts) -/user/username/projects/myproject/b.ts (computed .d.ts) -/user/username/projects/myproject/a.ts (used version) +No shapes updated in the builder:: exitCode:: ExitStatus.undefined @@ -436,20 +423,21 @@ Input:: Object.defineProperty(exports, "__esModule", { value: true }); exports.C = void 0; exports.foo = foo; -var C = /** @class */ (function () { - function C() { +exports.C = /** @class */ (function () { + function CReal() { this.d = 1; } - return C; + return CReal; }()); -exports.C = C; function foo() { } //// [/user/username/projects/myproject/c.d.ts] -export declare class C { - d: number; -} +export declare var C: { + new (): { + d: number; + }; +}; export declare function foo(): void; @@ -457,7 +445,7 @@ export declare function foo(): void; //// [/user/username/projects/myproject/b.d.ts] file written with same contents //// [/user/username/projects/myproject/a.d.ts] file written with same contents //// [/user/username/projects/myproject/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./c.ts","./b.ts","./a.ts","./d.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"840271342-export class C {\n d = 1;\n}export function foo() {}","signature":"-7819740442-export declare class C {\n d: number;\n}\nexport declare function foo(): void;\n","impliedFormat":1},{"version":"-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}","signature":"-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n","impliedFormat":1},{"version":"4878398349-import {B} from './b';\ndeclare var console: any;\nlet b = new B();\nconsole.log(b.c.d);","signature":"-3531856636-export {};\n","impliedFormat":1},{"version":"-7804761415-export class D { }","signature":"-8611429667-export declare class D {\n}\n","impliedFormat":1}],"root":[[2,5]],"options":{"declaration":true},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,4,3,2,5]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./c.ts","./b.ts","./a.ts","./d.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"-8116587914-export var C = class CReal {\n d = 1;\n};export function foo() {}","signature":"-544179862-export declare var C: {\n new (): {\n d: number;\n };\n};\nexport declare function foo(): void;\n","impliedFormat":1},{"version":"-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}","signature":"-12916012021-export declare class B {\n c: {\n d: number;\n };\n}\n","impliedFormat":1},{"version":"4878398349-import {B} from './b';\ndeclare var console: any;\nlet b = new B();\nconsole.log(b.c.d);","signature":"-3531856636-export {};\n","impliedFormat":1},{"version":"-7804761415-export class D { }","signature":"-8611429667-export declare class D {\n}\n","impliedFormat":1}],"root":[[2,5]],"options":{"declaration":true},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,4,3,2,5]},"version":"FakeTSVersion"} //// [/user/username/projects/myproject/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -491,22 +479,22 @@ export declare function foo(): void; }, "./c.ts": { "original": { - "version": "840271342-export class C {\n d = 1;\n}export function foo() {}", - "signature": "-7819740442-export declare class C {\n d: number;\n}\nexport declare function foo(): void;\n", + "version": "-8116587914-export var C = class CReal {\n d = 1;\n};export function foo() {}", + "signature": "-544179862-export declare var C: {\n new (): {\n d: number;\n };\n};\nexport declare function foo(): void;\n", "impliedFormat": 1 }, - "version": "840271342-export class C {\n d = 1;\n}export function foo() {}", - "signature": "-7819740442-export declare class C {\n d: number;\n}\nexport declare function foo(): void;\n", + "version": "-8116587914-export var C = class CReal {\n d = 1;\n};export function foo() {}", + "signature": "-544179862-export declare var C: {\n new (): {\n d: number;\n };\n};\nexport declare function foo(): void;\n", "impliedFormat": "commonjs" }, "./b.ts": { "original": { "version": "-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}", - "signature": "-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n", + "signature": "-12916012021-export declare class B {\n c: {\n d: number;\n };\n}\n", "impliedFormat": 1 }, "version": "-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}", - "signature": "-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n", + "signature": "-12916012021-export declare class B {\n c: {\n d: number;\n };\n}\n", "impliedFormat": "commonjs" }, "./a.ts": { @@ -564,7 +552,7 @@ export declare function foo(): void; ] }, "version": "FakeTSVersion", - "size": 1386 + "size": 1430 } diff --git a/tests/baselines/reference/tsc/cancellationToken/when-using-state.js b/tests/baselines/reference/tsc/cancellationToken/when-using-state.js index b1e4885668097..ec94b0431c6ef 100644 --- a/tests/baselines/reference/tsc/cancellationToken/when-using-state.js +++ b/tests/baselines/reference/tsc/cancellationToken/when-using-state.js @@ -13,9 +13,9 @@ export class B { } //// [/user/username/projects/myproject/c.ts] -export class C { +export var C = class CReal { d = 1; -} +}; //// [/user/username/projects/myproject/d.ts] export class D { } @@ -46,19 +46,20 @@ interface Array { length: number; [n: number]: T; } "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.C = void 0; -var C = /** @class */ (function () { - function C() { +exports.C = /** @class */ (function () { + function CReal() { this.d = 1; } - return C; + return CReal; }()); -exports.C = C; //// [/user/username/projects/myproject/c.d.ts] -export declare class C { - d: number; -} +export declare var C: { + new (): { + d: number; + }; +}; //// [/user/username/projects/myproject/b.js] @@ -76,9 +77,10 @@ exports.B = B; //// [/user/username/projects/myproject/b.d.ts] -import { C } from './c'; export declare class B { - c: C; + c: { + d: number; + }; } @@ -112,7 +114,7 @@ export declare class D { //// [/user/username/projects/myproject/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./c.ts","./b.ts","./a.ts","./d.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"-5130721255-export class C {\n d = 1;\n}","signature":"-6977846840-export declare class C {\n d: number;\n}\n","impliedFormat":1},{"version":"-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}","signature":"-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n","impliedFormat":1},{"version":"4878398349-import {B} from './b';\ndeclare var console: any;\nlet b = new B();\nconsole.log(b.c.d);","signature":"-3531856636-export {};\n","impliedFormat":1},{"version":"-7804761415-export class D { }","signature":"-8611429667-export declare class D {\n}\n","impliedFormat":1}],"root":[[2,5]],"options":{"declaration":true},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,4,3,2,5]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./c.ts","./b.ts","./a.ts","./d.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"6071811233-export var C = class CReal {\n d = 1;\n};","signature":"-2874569268-export declare var C: {\n new (): {\n d: number;\n };\n};\n","impliedFormat":1},{"version":"-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}","signature":"-12916012021-export declare class B {\n c: {\n d: number;\n };\n}\n","impliedFormat":1},{"version":"4878398349-import {B} from './b';\ndeclare var console: any;\nlet b = new B();\nconsole.log(b.c.d);","signature":"-3531856636-export {};\n","impliedFormat":1},{"version":"-7804761415-export class D { }","signature":"-8611429667-export declare class D {\n}\n","impliedFormat":1}],"root":[[2,5]],"options":{"declaration":true},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,4,3,2,5]},"version":"FakeTSVersion"} //// [/user/username/projects/myproject/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -146,22 +148,22 @@ export declare class D { }, "./c.ts": { "original": { - "version": "-5130721255-export class C {\n d = 1;\n}", - "signature": "-6977846840-export declare class C {\n d: number;\n}\n", + "version": "6071811233-export var C = class CReal {\n d = 1;\n};", + "signature": "-2874569268-export declare var C: {\n new (): {\n d: number;\n };\n};\n", "impliedFormat": 1 }, - "version": "-5130721255-export class C {\n d = 1;\n}", - "signature": "-6977846840-export declare class C {\n d: number;\n}\n", + "version": "6071811233-export var C = class CReal {\n d = 1;\n};", + "signature": "-2874569268-export declare var C: {\n new (): {\n d: number;\n };\n};\n", "impliedFormat": "commonjs" }, "./b.ts": { "original": { "version": "-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}", - "signature": "-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n", + "signature": "-12916012021-export declare class B {\n c: {\n d: number;\n };\n}\n", "impliedFormat": 1 }, "version": "-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}", - "signature": "-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n", + "signature": "-12916012021-export declare class B {\n c: {\n d: number;\n };\n}\n", "impliedFormat": "commonjs" }, "./a.ts": { @@ -219,7 +221,7 @@ export declare class D { ] }, "version": "FakeTSVersion", - "size": 1326 + "size": 1368 } @@ -262,9 +264,9 @@ Change:: Add change that affects d.ts Input:: //// [/user/username/projects/myproject/c.ts] -export class C { +export var C = class CReal { d = 1; -}export function foo() {} +};export function foo() {} Output:: @@ -273,7 +275,7 @@ Operation ws cancelled:: true //// [/user/username/projects/myproject/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./c.ts","./b.ts","./a.ts","./d.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"840271342-export class C {\n d = 1;\n}export function foo() {}","signature":"-6977846840-export declare class C {\n d: number;\n}\n","impliedFormat":1},{"version":"-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}","signature":"-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n","impliedFormat":1},{"version":"4878398349-import {B} from './b';\ndeclare var console: any;\nlet b = new B();\nconsole.log(b.c.d);","signature":"-3531856636-export {};\n","impliedFormat":1},{"version":"-7804761415-export class D { }","signature":"-8611429667-export declare class D {\n}\n","impliedFormat":1}],"root":[[2,5]],"options":{"declaration":true},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,3,5],"affectedFilesPendingEmit":[[4],2],"changeFileSet":[2]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./c.ts","./b.ts","./a.ts","./d.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"-8116587914-export var C = class CReal {\n d = 1;\n};export function foo() {}","signature":"-2874569268-export declare var C: {\n new (): {\n d: number;\n };\n};\n","impliedFormat":1},{"version":"-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}","signature":"-12916012021-export declare class B {\n c: {\n d: number;\n };\n}\n","impliedFormat":1},{"version":"4878398349-import {B} from './b';\ndeclare var console: any;\nlet b = new B();\nconsole.log(b.c.d);","signature":"-3531856636-export {};\n","impliedFormat":1},{"version":"-7804761415-export class D { }","signature":"-8611429667-export declare class D {\n}\n","impliedFormat":1}],"root":[[2,5]],"options":{"declaration":true},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,4,3,5],"changeFileSet":[2]},"version":"FakeTSVersion"} //// [/user/username/projects/myproject/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -307,22 +309,22 @@ Operation ws cancelled:: true }, "./c.ts": { "original": { - "version": "840271342-export class C {\n d = 1;\n}export function foo() {}", - "signature": "-6977846840-export declare class C {\n d: number;\n}\n", + "version": "-8116587914-export var C = class CReal {\n d = 1;\n};export function foo() {}", + "signature": "-2874569268-export declare var C: {\n new (): {\n d: number;\n };\n};\n", "impliedFormat": 1 }, - "version": "840271342-export class C {\n d = 1;\n}export function foo() {}", - "signature": "-6977846840-export declare class C {\n d: number;\n}\n", + "version": "-8116587914-export var C = class CReal {\n d = 1;\n};export function foo() {}", + "signature": "-2874569268-export declare var C: {\n new (): {\n d: number;\n };\n};\n", "impliedFormat": "commonjs" }, "./b.ts": { "original": { "version": "-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}", - "signature": "-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n", + "signature": "-12916012021-export declare class B {\n c: {\n d: number;\n };\n}\n", "impliedFormat": 1 }, "version": "-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}", - "signature": "-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n", + "signature": "-12916012021-export declare class B {\n c: {\n d: number;\n };\n}\n", "impliedFormat": "commonjs" }, "./a.ts": { @@ -373,27 +375,16 @@ Operation ws cancelled:: true }, "semanticDiagnosticsPerFile": [ "../../../../a/lib/lib.d.ts", + "./a.ts", "./b.ts", "./d.ts" ], - "affectedFilesPendingEmit": [ - [ - [ - "./a.ts" - ], - "Dts" - ], - [ - "./c.ts", - "Js | Dts" - ] - ], "changeFileSet": [ "./c.ts" ] }, "version": "FakeTSVersion", - "size": 1399 + "size": 1411 } @@ -418,12 +409,8 @@ Program files:: Semantic diagnostics in builder refreshed for:: /user/username/projects/myproject/c.ts -/user/username/projects/myproject/a.ts -Shape signatures in builder refreshed for:: -/user/username/projects/myproject/c.ts (computed .d.ts) -/user/username/projects/myproject/b.ts (computed .d.ts) -/user/username/projects/myproject/a.ts (used version) +No shapes updated in the builder:: exitCode:: ExitStatus.undefined @@ -436,20 +423,21 @@ Input:: Object.defineProperty(exports, "__esModule", { value: true }); exports.C = void 0; exports.foo = foo; -var C = /** @class */ (function () { - function C() { +exports.C = /** @class */ (function () { + function CReal() { this.d = 1; } - return C; + return CReal; }()); -exports.C = C; function foo() { } //// [/user/username/projects/myproject/c.d.ts] -export declare class C { - d: number; -} +export declare var C: { + new (): { + d: number; + }; +}; export declare function foo(): void; @@ -457,7 +445,7 @@ export declare function foo(): void; //// [/user/username/projects/myproject/b.d.ts] file written with same contents //// [/user/username/projects/myproject/a.d.ts] file written with same contents //// [/user/username/projects/myproject/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./c.ts","./b.ts","./a.ts","./d.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"840271342-export class C {\n d = 1;\n}export function foo() {}","signature":"-7819740442-export declare class C {\n d: number;\n}\nexport declare function foo(): void;\n","impliedFormat":1},{"version":"-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}","signature":"-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n","impliedFormat":1},{"version":"4878398349-import {B} from './b';\ndeclare var console: any;\nlet b = new B();\nconsole.log(b.c.d);","signature":"-3531856636-export {};\n","impliedFormat":1},{"version":"-7804761415-export class D { }","signature":"-8611429667-export declare class D {\n}\n","impliedFormat":1}],"root":[[2,5]],"options":{"declaration":true},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,4,3,2,5]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../../a/lib/lib.d.ts","./c.ts","./b.ts","./a.ts","./d.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},{"version":"-8116587914-export var C = class CReal {\n d = 1;\n};export function foo() {}","signature":"-544179862-export declare var C: {\n new (): {\n d: number;\n };\n};\nexport declare function foo(): void;\n","impliedFormat":1},{"version":"-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}","signature":"-12916012021-export declare class B {\n c: {\n d: number;\n };\n}\n","impliedFormat":1},{"version":"4878398349-import {B} from './b';\ndeclare var console: any;\nlet b = new B();\nconsole.log(b.c.d);","signature":"-3531856636-export {};\n","impliedFormat":1},{"version":"-7804761415-export class D { }","signature":"-8611429667-export declare class D {\n}\n","impliedFormat":1}],"root":[[2,5]],"options":{"declaration":true},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,4,3,2,5]},"version":"FakeTSVersion"} //// [/user/username/projects/myproject/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -491,22 +479,22 @@ export declare function foo(): void; }, "./c.ts": { "original": { - "version": "840271342-export class C {\n d = 1;\n}export function foo() {}", - "signature": "-7819740442-export declare class C {\n d: number;\n}\nexport declare function foo(): void;\n", + "version": "-8116587914-export var C = class CReal {\n d = 1;\n};export function foo() {}", + "signature": "-544179862-export declare var C: {\n new (): {\n d: number;\n };\n};\nexport declare function foo(): void;\n", "impliedFormat": 1 }, - "version": "840271342-export class C {\n d = 1;\n}export function foo() {}", - "signature": "-7819740442-export declare class C {\n d: number;\n}\nexport declare function foo(): void;\n", + "version": "-8116587914-export var C = class CReal {\n d = 1;\n};export function foo() {}", + "signature": "-544179862-export declare var C: {\n new (): {\n d: number;\n };\n};\nexport declare function foo(): void;\n", "impliedFormat": "commonjs" }, "./b.ts": { "original": { "version": "-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}", - "signature": "-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n", + "signature": "-12916012021-export declare class B {\n c: {\n d: number;\n };\n}\n", "impliedFormat": 1 }, "version": "-6441446591-import {C} from './c';\nexport class B {\n c = new C();\n}", - "signature": "-165097315-import { C } from './c';\nexport declare class B {\n c: C;\n}\n", + "signature": "-12916012021-export declare class B {\n c: {\n d: number;\n };\n}\n", "impliedFormat": "commonjs" }, "./a.ts": { @@ -564,7 +552,7 @@ export declare function foo(): void; ] }, "version": "FakeTSVersion", - "size": 1386 + "size": 1430 } From 5cc1ea4887474ace8be203c7c36017af6828a329 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 20 May 2024 16:03:51 -0700 Subject: [PATCH 5/7] Remove debugging leftover --- src/testRunner/unittests/tsc/cancellationToken.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testRunner/unittests/tsc/cancellationToken.ts b/src/testRunner/unittests/tsc/cancellationToken.ts index 1570680b63fd1..a9b1406192318 100644 --- a/src/testRunner/unittests/tsc/cancellationToken.ts +++ b/src/testRunner/unittests/tsc/cancellationToken.ts @@ -17,7 +17,7 @@ import { libFile, } from "../helpers/virtualFileSystemWithWatch.js"; -describe("unittests:: tsc:: builder cancellationToken:: sheetal", () => { +describe("unittests:: tsc:: builder cancellationToken::", () => { verifyCancellation(/*useBuildInfo*/ true, "when emitting buildInfo"); verifyCancellation(/*useBuildInfo*/ false, "when using state"); function verifyCancellation(useBuildInfo: boolean, scenario: string) { From 0a2338103d82bdb1a3b5c0b73a1b137054c8dfb7 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 21 May 2024 09:40:40 -0700 Subject: [PATCH 6/7] Check directly for forceDtsEmit before getting diagnostics and returning emitResolver --- src/compiler/checker.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 687e754ab403b..9440eaea7e8bb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2431,7 +2431,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function getEmitResolver(sourceFile: SourceFile, cancellationToken: CancellationToken, forceDtsEmit?: boolean) { // Ensure we have all the type information in place for this file so that all the // emitter questions of this resolver will return the right information. - getDiagnostics(sourceFile, cancellationToken, forceDtsEmit); + if (!forceDtsEmit) getDiagnostics(sourceFile, cancellationToken); return emitResolver; } @@ -47483,10 +47483,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { tracing?.pop(); } - function checkSourceFile(node: SourceFile, forceDtsEmit: boolean | undefined) { + function checkSourceFile(node: SourceFile) { tracing?.push(tracing.Phase.Check, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); performance.mark("beforeCheck"); - checkSourceFileWorker(node, forceDtsEmit); + checkSourceFileWorker(node); performance.mark("afterCheck"); performance.measure("Check", "beforeCheck", "afterCheck"); tracing?.pop(); @@ -47511,10 +47511,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } // Fully type check a source file and collect the relevant diagnostics. - function checkSourceFileWorker(node: SourceFile, forceDtsEmit: boolean | undefined) { + function checkSourceFileWorker(node: SourceFile) { const links = getNodeLinks(node); if (!(links.flags & NodeCheckFlags.TypeChecked)) { - if (forceDtsEmit || skipTypeChecking(node, compilerOptions, host)) { + if (skipTypeChecking(node, compilerOptions, host)) { return; } @@ -47578,13 +47578,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } - function getDiagnostics(sourceFile: SourceFile, ct: CancellationToken, forceDtsEmit?: boolean): Diagnostic[] { + function getDiagnostics(sourceFile: SourceFile, ct: CancellationToken): Diagnostic[] { try { // Record the cancellation token so it can be checked later on during checkSourceElement. // Do this in a finally block so we can ensure that it gets reset back to nothing after // this call is done. cancellationToken = ct; - return getDiagnosticsWorker(sourceFile, forceDtsEmit); + return getDiagnosticsWorker(sourceFile); } finally { cancellationToken = undefined; @@ -47599,7 +47599,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { deferredDiagnosticsCallbacks = []; } - function checkSourceFileWithEagerDiagnostics(sourceFile: SourceFile, forceDtsEmit?: boolean) { + function checkSourceFileWithEagerDiagnostics(sourceFile: SourceFile) { ensurePendingDiagnosticWorkComplete(); // then setup diagnostics for immediate invocation (as we are about to collect them, and // this avoids the overhead of longer-lived callbacks we don't need to allocate) @@ -47608,11 +47608,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // thus much more likely retaining the same union ordering as before we had lazy diagnostics) const oldAddLazyDiagnostics = addLazyDiagnostic; addLazyDiagnostic = cb => cb(); - checkSourceFile(sourceFile, forceDtsEmit); + checkSourceFile(sourceFile); addLazyDiagnostic = oldAddLazyDiagnostics; } - function getDiagnosticsWorker(sourceFile: SourceFile, forceDtsEmit: boolean | undefined): Diagnostic[] { + function getDiagnosticsWorker(sourceFile: SourceFile): Diagnostic[] { if (sourceFile) { ensurePendingDiagnosticWorkComplete(); // Some global diagnostics are deferred until they are needed and @@ -47621,7 +47621,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics(); const previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length; - checkSourceFileWithEagerDiagnostics(sourceFile, forceDtsEmit); + checkSourceFileWithEagerDiagnostics(sourceFile); const semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); const currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics(); @@ -47642,7 +47642,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // Global diagnostics are always added when a file is not provided to // getDiagnostics - forEach(host.getSourceFiles(), sourceFile => checkSourceFileWithEagerDiagnostics(sourceFile, forceDtsEmit)); + forEach(host.getSourceFiles(), checkSourceFileWithEagerDiagnostics); return diagnostics.getDiagnostics(); } From c4af1f59d1f4966e0ad8fc58aaebd08c6ff58ddb Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 21 May 2024 12:43:10 -0700 Subject: [PATCH 7/7] Handle emitOnlyDts for now since #58364 is yet to be merged for js emit to be done without type checking --- src/compiler/checker.ts | 4 ++-- src/compiler/emitter.ts | 11 ++++++++++- src/compiler/program.ts | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9440eaea7e8bb..9a6056606f9c3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2428,10 +2428,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return visitEachChild(node, markAsSynthetic, /*context*/ undefined); } - function getEmitResolver(sourceFile: SourceFile, cancellationToken: CancellationToken, forceDtsEmit?: boolean) { + function getEmitResolver(sourceFile: SourceFile, cancellationToken: CancellationToken, skipDiagnostics?: boolean) { // Ensure we have all the type information in place for this file so that all the // emitter questions of this resolver will return the right information. - if (!forceDtsEmit) getDiagnostics(sourceFile, cancellationToken); + if (!skipDiagnostics) getDiagnostics(sourceFile, cancellationToken); return emitResolver; } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 5934a4358d6bd..67eec856db5ae 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -717,6 +717,11 @@ export function getFirstProjectOutput(configFile: ParsedCommandLine, ignoreCase: return Debug.fail(`project ${configFile.options.configFilePath} expected to have at least one output`); } +/** @internal */ +export function emitResolverSkipsTypeChecking(emitOnly: boolean | EmitOnly | undefined, forceDtsEmit: boolean | undefined) { + return !!forceDtsEmit && !!emitOnly; +} + /** @internal */ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFile: SourceFile | undefined, { scriptTransformers, declarationTransformers }: EmitTransformers, emitOnly?: boolean | EmitOnly, onlyBuildInfo?: boolean, forceDtsEmit?: boolean): EmitResult { @@ -848,7 +853,11 @@ export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFi const filesForEmit = forceDtsEmit ? sourceFiles : filter(sourceFiles, isSourceFileNotJson); // Setup and perform the transformation to retrieve declarations from the input files const inputListOrBundle = compilerOptions.outFile ? [factory.createBundle(filesForEmit)] : filesForEmit; - if ((emitOnly && !getEmitDeclarations(compilerOptions)) || compilerOptions.noCheck || forceDtsEmit) { + if ( + (emitOnly && !getEmitDeclarations(compilerOptions)) || + compilerOptions.noCheck || + emitResolverSkipsTypeChecking(emitOnly, forceDtsEmit) + ) { // Checker wont collect the linked aliases since thats only done when declaration is enabled and checking is performed. // Do that here when emitting only dts files filesForEmit.forEach(collectLinkedAliases); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 6b5ad01ed9da1..09f4ed4ff6f3d 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -68,6 +68,7 @@ import { EmitHost, emitModuleKindIsNonNodeESM, EmitOnly, + emitResolverSkipsTypeChecking, EmitResult, emptyArray, ensureTrailingDirectorySeparator, @@ -2874,7 +2875,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg const emitResolver = typeChecker.getEmitResolver( options.outFile ? undefined : sourceFile, cancellationToken, - forceDtsEmit, + emitResolverSkipsTypeChecking(emitOnly, forceDtsEmit), ); performance.mark("beforeEmit");