Skip to content

Commit ac746e4

Browse files
authored
fix: dont trace ts type imports (#387)
1 parent bea0932 commit ac746e4

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/trace/ts.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,15 @@ export async function createTsAnalysis(
8585
return {
8686
visitor: {
8787
ExportAllDeclaration(path) {
88-
imports.add(path.node.source.value);
88+
if (path.node.exportKind !== 'type')
89+
imports.add(path.node.source.value);
8990
},
9091
ExportNamedDeclaration(path) {
9192
if (path.node.source) imports.add(path.node.source.value);
9293
},
9394
ImportDeclaration(path) {
94-
imports.add(path.node.source.value);
95+
if (path.node.exportKind !== 'type')
96+
imports.add(path.node.source.value);
9597
},
9698
Import(path) {
9799
dynamicImports.add(

test/resolve/tspkg/main.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
import type { t } from './types.ts';
12
import "./dep.ts";
2-
export var p: number = 5;
3+
export var p: t = 5;

test/resolve/tspkg/types.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// should not be traced!
2+
import 'jquery';
3+
4+
export type t = number;

0 commit comments

Comments
 (0)