Skip to content

Commit

Permalink
Better support for out of order checking for type only alias marking
Browse files Browse the repository at this point in the history
  • Loading branch information
weswigham committed Apr 30, 2024
1 parent 80da691 commit 699039b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
7 changes: 7 additions & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4241,6 +4241,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
return undefined;
}
const links = getSymbolLinks(symbol);
if (links.typeOnlyDeclaration === undefined) {
// We need to set a WIP value here to prevent reentrancy during `getImmediateAliasedSymbol` which, paradoxically, can depend on this
links.typeOnlyDeclaration = false;
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
// 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
markSymbolOfAliasDeclarationIfTypeOnly(symbol.declarations?.[0], getDeclarationOfAliasSymbol(symbol) && getImmediateAliasedSymbol(symbol), resolved, /*overwriteEmpty*/ true);
}
if (include === undefined) {
return links.typeOnlyDeclaration || undefined;
}
Expand Down
12 changes: 0 additions & 12 deletions tests/baselines/reference/verbatimModuleSyntaxRestrictionsCJS.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,3 @@ exports.default = I; // error
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = esmy; // error


!!!! File /main7.js differs from original emit in noCheck emit
//// [main7.js]
===================================================================
--- Expected The full check baseline
+++ Actual with noCheck set
@@ -1,3 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.default = esmy; // error
+exports.default = decl_1.default; // error

0 comments on commit 699039b

Please sign in to comment.