fix(resolution): leave built-in Map calls unresolved (#1566) (#1790)

Co-authored-by: Colby McHenry <colbymchenry@users.noreply.github.com>
This commit is contained in:
Colby Mchenry
2026-09-08 14:04:43 -05:00
committed by GitHub
co-authored by Colby McHenry
parent 72c1ff13cc
commit de5adba7ea
9 changed files with 151 additions and 59 deletions
+1 -8
View File
@@ -29,6 +29,7 @@ import { logDebug } from '../errors';
import { lexicalPathWithinRoot } from '../utils';
import type { ReExport } from './types';
import { LRUCache } from './lru-cache';
import { JS_BUILT_INS } from './js-builtins';
/** Node kinds that can declare supertypes (extends/implements). */
const SUPERTYPE_BEARING_KINDS = new Set<Node['kind']>([
@@ -70,14 +71,6 @@ function resolveCacheLimit(): number {
export * from './types';
// Pre-built Sets for O(1) built-in lookups (allocated once, shared across all instances)
const JS_BUILT_INS = new Set([
'console', 'window', 'document', 'global', 'process',
'Promise', 'Array', 'Object', 'String', 'Number', 'Boolean',
'Date', 'Math', 'JSON', 'RegExp', 'Error', 'Map', 'Set',
'setTimeout', 'setInterval', 'clearTimeout', 'clearInterval',
'fetch', 'require', 'module', 'exports', '__dirname', '__filename',
]);
const REACT_HOOKS = new Set([
'useState', 'useEffect', 'useContext', 'useReducer', 'useCallback',
'useMemo', 'useRef', 'useLayoutEffect', 'useImperativeHandle', 'useDebugValue',
+8
View File
@@ -0,0 +1,8 @@
/** Shared JS/TS built-ins for direct references and inferred receiver types. */
export const JS_BUILT_INS = new Set([
'console', 'window', 'document', 'global', 'process',
'Promise', 'Array', 'Object', 'String', 'Number', 'Boolean',
'Date', 'Math', 'JSON', 'RegExp', 'Error', 'Map', 'Set', 'WeakMap', 'WeakSet',
'setTimeout', 'setInterval', 'clearTimeout', 'clearInterval',
'fetch', 'require', 'module', 'exports', '__dirname', '__filename',
]);
+8
View File
@@ -8,6 +8,7 @@ import * as path from 'path';
import { Language, Node } from '../types';
import { UnresolvedRef, ResolvedRef, ResolutionContext } from './types';
import { blankStringContents, stripCommentsForRegex } from './strip-comments';
import { JS_BUILT_INS } from './js-builtins';
/**
* Ceiling on how many same-named definitions a FUZZY name-match strategy will
@@ -2194,6 +2195,13 @@ export function matchMethodCall(
if (typedMatch) {
return typedMatch;
}
// A known JS/TS builtin receiver is external when it has no project
// method (#1566). Inference already strips generics (`Map<K, V>` →
// `Map`); do not let Strategy 3 guess an unrelated `get`/`set`/`has`.
// Keep the validated match above for a project type shadowing a builtin.
if (ESM_FAMILY.has(ref.language) && JS_BUILT_INS.has(inferredType)) {
return null;
}
}
}