Skip to content

Fix maybeMappedType function#3529

Merged
ahejlsberg merged 2 commits into
mainfrom
fix-3509
Apr 23, 2026
Merged

Fix maybeMappedType function#3529
ahejlsberg merged 2 commits into
mainfrom
fix-3509

Conversation

@ahejlsberg
Copy link
Copy Markdown
Member

Fixes #3509.

Copy link
Copy Markdown
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

Fixes the TypeScript-Go checker’s mapped-type “Did you mean P in K?” suggestion so that TS2690 is reported (with the suggestion) instead of falling back to the generic TS2693, aligning output with the upstream TypeScript baselines and resolving #3509.

Changes:

  • Fix Checker.maybeMappedType to walk up from the identifier to the computed property/type literal context before deciding to emit the mapped-type suggestion.
  • Tighten the key-type check for the suggestion using allTypesAssignableToKindEx(..., strict=true) so any/unknown/null/undefined don’t incorrectly qualify.
  • Update/clean up baselines and triage tracking now that the output matches the submodule expectations.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
internal/checker/checker.go Corrects ancestor-walk logic in maybeMappedType and refines the “is union of string/number literals” check to restore mapped-type suggestion diagnostics.
testdata/submoduleTriaged.txt Removes the triage entry for #3509 since it’s no longer a known baseline mismatch.
testdata/baselines/reference/submoduleTriaged/compiler/typeUsedAsTypeLiteralIndex.errors.txt.diff Deletes the triaged diff baseline because the mismatch is resolved.
testdata/baselines/reference/submodule/compiler/typeUsedAsTypeLiteralIndex.errors.txt Updates the reference baseline to reflect the restored TS2690 + suggestion output.

@ahejlsberg ahejlsberg added this pull request to the merge queue Apr 23, 2026
Merged via the queue into main with commit fd9bbdb Apr 23, 2026
39 of 43 checks passed
@ahejlsberg ahejlsberg deleted the fix-3509 branch April 23, 2026 18:13
@gabritto gabritto mentioned this pull request Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants