Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Conversation

@bm-w
Copy link

@bm-w bm-w commented Apr 3, 2025

The stanza dealing template_literal_type syntax nodes is too liberal in its capturing of inner types, causing it to capture string_fragment syntax nodes and fail creating edges with an error like:

0: Error executing statement edge @inner.lexical_scope -> @type.lexical_scope at (5775, 3)
     src/stack-graphs.tsg:5775:3:
     5775 |   edge @inner.lexical_scope -> @type.lexical_scope
          |   ^
     in stanza
     src/stack-graphs.tsg:5773:1:
     5773 | (template_literal_type (_)@inner)@type {
          | ^
     matching (template_literal_type) node
     test/types/template-literal-type.ts:2:17:
     2 | type Greeting = `Hello, ${World}!`;
       |                 ^
1: Evaluating edge source
2: Undefined scoped variable [syntax node string_fragment (2, 18)].lexical_scope

Restricting the inner type capture to just template_type syntax node fixes the issue. As of v0.23.2 of the Tree-sitter TypeScript grammar the template_literal_type only allows string_fragment and template_type children, so this fix should be fine. Copious testing (on this repo’s TypeScript test suite and on all of microsoft/vscode) reveals no negative side effects.

Copilot AI review requested due to automatic review settings April 3, 2025 16:39
@bm-w bm-w requested review from a team as code owners April 3, 2025 16:39
Copy link

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

This PR fixes the template literal type parsing by restricting the capture of inner types to just the "template_type" syntax node, addressing an issue where "string_fragment" nodes were incorrectly captured.

  • Restricts inner type capture for template literal types
  • Adds a test case to verify the change
Files not reviewed (1)
  • languages/tree-sitter-stack-graphs-typescript/src/stack-graphs.tsg: Language not supported

@CleanCut
Copy link
Contributor

CleanCut commented Sep 9, 2025

The github/stack-graphs repository is no longer being maintained. As per #502, I'm closing all issues and pull requests before archiving the repository.

@CleanCut CleanCut closed this Sep 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants