Skip to content

Port proposal-upsert methods to getScriptTargetFeatures#2809

Merged
jakebailey merged 3 commits intomainfrom
copilot/port-proposal-upsert-methods
Feb 17, 2026
Merged

Port proposal-upsert methods to getScriptTargetFeatures#2809
jakebailey merged 3 commits intomainfrom
copilot/port-proposal-upsert-methods

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

  • Add esnext entries for getOrInsert and getOrInsertComputed to Map and WeakMap in script target features
  • Remove incorrect entries/keys/values props from WeakMap and WeakSet es2015 entries (these types are not iterable)
  • Keep es2015 lib entries with empty props so "did you mean" suggestions still work
  • All tests pass

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…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>
Copilot AI changed the title [WIP] Port proposal-upsert methods to lib.esnext.collection Port proposal-upsert methods to getScriptTargetFeatures Feb 17, 2026
Copilot AI requested a review from jakebailey February 17, 2026 19:12
@jakebailey jakebailey marked this pull request as ready for review February 17, 2026 19:48
Copilot AI review requested due to automatic review settings February 17, 2026 19:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 esnext feature-map entries for Map.getOrInsert and Map.getOrInsertComputed.
  • Added esnext feature-map entries for WeakMap.getOrInsert and WeakMap.getOrInsertComputed.
Comments suppressed due to low confidence (1)

internal/checker/utilities.go:1411

  • Similarly, WeakSet is not iterable, so entries/keys/values shouldn’t be listed as es2015 features here (the bundled libs define interface WeakSet ... {} with no iterable members). Removing these avoids misleading lib-target suggestions for WeakSet.entries() etc.
		"WeakSet": {
			{lib: "es2015", props: []string{"entries", "keys", "values"}},
		},

Comment on lines 1402 to +1404
"WeakMap": {
{lib: "es2015", props: []string{"entries", "keys", "values"}},
{lib: "esnext", props: []string{
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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>
@DanielRosenwasser
Copy link
Member

@jakebailey jakebailey added this pull request to the merge queue Feb 17, 2026
Merged via the queue into main with commit 23f38a8 Feb 17, 2026
20 checks passed
@jakebailey jakebailey deleted the copilot/port-proposal-upsert-methods branch February 17, 2026 23:30
Copilot AI added a commit that referenced this pull request Feb 25, 2026
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants