Skip to content

Fixed an accidental undefined leak into getAccessibleSymbolChain's cache key #58669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5473,7 +5473,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
const cache = (links.accessibleChainCache ||= new Map());
// Go from enclosingDeclaration to the first scope we check, so the cache is keyed off the scope and thus shared more
const firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, (_, __, ___, node) => node);
const key = `${useOnlyExternalAliasing ? 0 : 1}|${firstRelevantLocation && getNodeId(firstRelevantLocation)}|${meaning}`;
const key = `${useOnlyExternalAliasing ? 0 : 1}|${firstRelevantLocation ? getNodeId(firstRelevantLocation) : 0}|${meaning}`;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that those keys could look smth like '0|undefined|788968' (I spotted an instance of that in the debugger). It bugged me enough to create this PR ;p

0 should be a safe fallback here as the lowest possible node id is 1

if (cache.has(key)) {
return cache.get(key);
}
Expand Down