diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index df8026b71ec3a..2a914ab0ec325 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, 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. - getDiagnostics(sourceFile, cancellationToken); + if (!skipDiagnostics) getDiagnostics(sourceFile, cancellationToken); return emitResolver; } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 03fe0e5e3859e..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) { + 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 dfb878c6265a0..09f4ed4ff6f3d 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -68,6 +68,7 @@ import { EmitHost, emitModuleKindIsNonNodeESM, EmitOnly, + emitResolverSkipsTypeChecking, EmitResult, emptyArray, ensureTrailingDirectorySeparator, @@ -2870,18 +2871,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); + const typeChecker = getTypeChecker(); + const emitResolver = typeChecker.getEmitResolver( + options.outFile ? undefined : sourceFile, + cancellationToken, + emitResolverSkipsTypeChecking(emitOnly, 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 c074a85e4ed8a..97cd0a4cd889a 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; @@ -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..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", () => { +describe("unittests:: tsc:: builder cancellationToken::", () => { 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 5c9a2900a5b8f..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,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":"-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": { @@ -382,7 +384,7 @@ Operation ws cancelled:: true ] }, "version": "FakeTSVersion", - "size": 1366 + "size": 1411 } @@ -421,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; @@ -442,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] { @@ -476,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": { @@ -549,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 8370dc648cff3..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,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":"-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": { @@ -382,7 +384,7 @@ Operation ws cancelled:: true ] }, "version": "FakeTSVersion", - "size": 1366 + "size": 1411 } @@ -421,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; @@ -442,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] { @@ -476,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": { @@ -549,7 +552,7 @@ export declare function foo(): void; ] }, "version": "FakeTSVersion", - "size": 1386 + "size": 1430 }