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

Commit 63e2d6e

Browse files
Merge pull request #437 from nohehf/fix/ts-imports-extensions
2 parents 558d1da + c43fa8b commit 63e2d6e

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

languages/tree-sitter-stack-graphs-typescript/src/stack-graphs.tsg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,8 @@ attribute node_symbol = node => symbol = (source-text node), source_n
540540

541541
; module reference
542542
var mod_scope = mod_ref__ns
543-
scan (path-normalize mod_path) {
543+
; normalize path and remove the extension as we want to match 'foo', 'foo.js', 'foo.ts', etc.
544+
scan (path-normalize (replace mod_path "\.(js|ts|jsx|tsx)$" "")) {
544545
"([^/]+)/?" {
545546
node mod_ref
546547
attr (mod_ref) push_symbol = $1
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* --- path: src/foo.ts --- */
2+
export const bar = 42;
3+
4+
/* --- path: src/index.ts --- */
5+
import { bar } from "./foo.js";
6+
// ^ defined: 2
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* --- path: src/foo.ts --- */
2+
export const bar = 42;
3+
4+
/* --- path: src/index.ts --- */
5+
import { bar } from "./foo";
6+
// ^ defined: 2
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* --- path: src/foo.ts --- */
2+
export const bar = 42;
3+
4+
/* --- path: src/index.ts --- */
5+
import { bar } from "./foo.ts";
6+
// ^ defined: 2

0 commit comments

Comments
 (0)