Skip to content

Fix language service crash on super type arguments before a template literal - #65699

Open
Jake Bailey (jakebailey) wants to merge 2 commits into
microsoft:mainfrom
jakebailey:fix-super-tagged-template-crash
Open

Jake Bailey (jakebailey) wants to merge 2 commits into
microsoft:mainfrom
jakebailey:fix-super-tagged-template-crash

Conversation

@jakebailey

Copy link
Copy Markdown
Member

This was found by fuzzing language service queries over taggedTemplatesWithTypeArguments2.ts as part of #65064.

When super<T> is followed by a template literal, the parser drops the type arguments and builds the missing super. name after them, so the property access spans <T> without a node for that text. Document highlights or find-all-references on a type parameter named in that list then crash with "did not expect KindPropertyAccessExpression to have KindIdentifier in its trivia". TypeScript 6.0 builds the same tree and fails the same assertion.

The parser now ends the property access at super and keeps the type arguments as nodes on the tagged template, so references inside them resolve. The diagnostics and emit of the existing test are unchanged.

Document highlights and find-all-references on a type parameter whose
class calls `super<number, string, T>` followed by a template literal
panic in astnav.getTokenAtPosition with "did not expect
KindPropertyAccessExpression to have KindIdentifier in its trivia".

The panic aborts the request, so this commit has no baselines and the
test fails with that panic until the parser is fixed.
When `super<T>` is followed by a template literal, the parser dropped
the type arguments but still reported the template's missing `super.`
name after them. The resulting property access covered the text
`<T>` without having a node for it. Anything that visits identifiers
by text position, such as find-all-references and document
highlights on a type parameter named in that list, then asked
astnav.getTokenAtPosition for a token that only the scanner could
produce, and it panicked with "did not expect
KindPropertyAccessExpression to have KindIdentifier in its trivia".

Now the property access ends right after `super`, and the type
arguments travel to the tagged template through the existing
ExpressionWithTypeArguments absorption in parseMemberExpressionRest.
Every node range covers only its children, and the type arguments are
real nodes that the checker and the language service can see. The
diagnostics and the emit for the test case are unchanged. The type
parameter now gets a symbol entry in the baseline because the checker
visits the type arguments.
Copilot AI balanced review requested due to automatic review settings November 26, 2026 17:22
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 26, 2026
@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 26, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the parser recovery change addressing language-service crashes with super tagged templates.

No open issues 🎉

What changed in this PR

Fixes a language-service crash found during fuzzing for #65064 when super<T> precedes a template literal. The parser preserves the type arguments as navigable nodes, allowing document highlights and reference searches to resolve them.

Changes:

  • Ends the recovered property access at super and transfers the type arguments to the tagged template.
  • Adds a fourslash regression test for document highlights and find-all-references.
  • Updates type, symbol, and language-service baselines to reflect the corrected tree and references.
File Description
tsc/​testdata/​baselines/​reference/​fourslash/​findAllReferences/​superTaggedTemplateTypeArgumentsNoCrash.baseline.jsonc Records references from the declaration, super, and type argument.
tsc/​testdata/​baselines/​reference/​fourslash/​documentHighlights/​superTaggedTemplateTypeArgumentsNoCrash.baseline.jsonc Records highlights at the three regression-test markers.
tsc/​testdata/​baselines/​reference/​conformance/​taggedTemplatesWithTypeArguments2.types Reflects the shortened property-access span.
tsc/​testdata/​baselines/​reference/​conformance/​taggedTemplatesWithTypeArguments2.symbols Records the retained type argument’s symbol.
tsc/​internal/​parser/​parser.go Preserves type arguments during recovery of invalid super tagged templates.
tsc/​internal/​fourslash/​tests/​superTaggedTemplateTypeArgumentsNoCrash_test.go Adds regression coverage for both language-service queries.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

2 participants