Skip to content

Commit 699039b

Browse files
committed
Better support for out of order checking for type only alias marking
1 parent 80da691 commit 699039b

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

src/compiler/checker.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4241,6 +4241,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
42414241
return undefined;
42424242
}
42434243
const links = getSymbolLinks(symbol);
4244+
if (links.typeOnlyDeclaration === undefined) {
4245+
// We need to set a WIP value here to prevent reentrancy during `getImmediateAliasedSymbol` which, paradoxically, can depend on this
4246+
links.typeOnlyDeclaration = false;
4247+
const resolved = resolveSymbol(symbol); // do this before the `resolveImmediate` below, as it uses a different circularity cache and we might hide a circularity error if we blindly get the immediate alias first
4248+
// While usually the alias will have been marked during the pass by the full typecheck, we may still need to calculate the alias declaration now
4249+
markSymbolOfAliasDeclarationIfTypeOnly(symbol.declarations?.[0], getDeclarationOfAliasSymbol(symbol) && getImmediateAliasedSymbol(symbol), resolved, /*overwriteEmpty*/ true);
4250+
}
42444251
if (include === undefined) {
42454252
return links.typeOnlyDeclaration || undefined;
42464253
}

tests/baselines/reference/verbatimModuleSyntaxRestrictionsCJS.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,3 @@ exports.default = I; // error
123123
"use strict";
124124
Object.defineProperty(exports, "__esModule", { value: true });
125125
exports.default = esmy; // error
126-
127-
128-
!!!! File /main7.js differs from original emit in noCheck emit
129-
//// [main7.js]
130-
===================================================================
131-
--- Expected The full check baseline
132-
+++ Actual with noCheck set
133-
@@ -1,3 +1,3 @@
134-
"use strict";
135-
Object.defineProperty(exports, "__esModule", { value: true });
136-
-exports.default = esmy; // error
137-
+exports.default = decl_1.default; // error

0 commit comments

Comments
 (0)