Port proposal-upsert methods to getScriptTargetFeatures#2809
Port proposal-upsert methods to getScriptTargetFeatures#2809jakebailey merged 3 commits intomainfrom
Conversation
…target features Port getScriptTargetFeatures changes from TypeScript PR #62612 to add esnext entries for the proposal-upsert methods (getOrInsert and getOrInsertComputed) to Map and WeakMap. Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Ports TypeScript’s getScriptTargetFeatures updates for the new Map/WeakMap “proposal-upsert” methods so lib-target suggestion diagnostics can recognize getOrInsert and getOrInsertComputed when esnext libs are in use.
Changes:
- Added
esnextfeature-map entries forMap.getOrInsertandMap.getOrInsertComputed. - Added
esnextfeature-map entries forWeakMap.getOrInsertandWeakMap.getOrInsertComputed.
Comments suppressed due to low confidence (1)
internal/checker/utilities.go:1411
- Similarly,
WeakSetis not iterable, soentries/keys/valuesshouldn’t be listed ases2015features here (the bundled libs defineinterface WeakSet ... {}with no iterable members). Removing these avoids misleading lib-target suggestions forWeakSet.entries()etc.
"WeakSet": {
{lib: "es2015", props: []string{"entries", "keys", "values"}},
},
| "WeakMap": { | ||
| {lib: "es2015", props: []string{"entries", "keys", "values"}}, | ||
| {lib: "esnext", props: []string{ |
There was a problem hiding this comment.
The feature map lists entries, keys, and values on WeakMap under es2015, but WeakMap is not iterable and these members don't exist in the bundled lib declarations (e.g. lib.es2015.collection.d.ts / lib.es2015.iterable.d.ts). This will make the “try changing the 'lib'…” suggestions incorrect for WeakMap.entries() etc. Remove these props (or drop the WeakMap iterable entry entirely) so only real WeakMap members are mapped.
There was a problem hiding this comment.
Fixed in 3a7bf1b. Replaced the incorrect entries/keys/values props with empty lists for both WeakMap and WeakSet, since these types are not iterable. Kept the es2015 lib entries (with empty props, like Promise does) so that getSuggestedLibForNonExistentName still correctly suggests es2015 for WeakMap/WeakSet.
… map WeakMap and WeakSet are not iterable and don't have entries(), keys(), or values() methods. Replace the incorrect props with empty lists while keeping the es2015 lib entries so that "did you mean" suggestions correctly point to es2015. Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
esnextentries forgetOrInsertandgetOrInsertComputedtoMapandWeakMapin script target featuresentries/keys/valuesprops fromWeakMapandWeakSetes2015 entries (these types are not iterable)es2015lib entries with empty props so "did you mean" suggestions still work💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.