@@ -199,7 +199,7 @@ def test_type_import_counts_as_used(self, tmp_path):
199199 assert "Foo" not in unused_names
200200
201201 def test_mixed_default_and_named_import_counts_as_used (self , tmp_path ):
202- """import默认 + named should mark both as used."""
202+ """Default + named should mark both as used."""
203203 mod = tmp_path / "mod.ts"
204204 mod .write_text ('export function myFunc() { return 1; }\n ' )
205205 app = tmp_path / "app.ts"
@@ -212,6 +212,33 @@ def test_mixed_default_and_named_import_counts_as_used(self, tmp_path):
212212 assert "myFunc" not in unused_names
213213 assert "Default" not in unused_names
214214
215+ def test_type_only_import_marks_as_used (self , tmp_path ):
216+ """`import { type Foo } from ...` should mark Foo as used."""
217+ mod = tmp_path / "mod.ts"
218+ mod .write_text ('export type Foo = string;\n ' )
219+ app = tmp_path / "app.ts"
220+ app .write_text ('import { type Foo } from "./mod";\n const x: Foo = "hi";\n ' )
221+
222+ scanner = DeadCodeScanner (tmp_path )
223+ result = scanner .scan ()
224+
225+ unused_names = {f .name for f in result .unused_exports }
226+ assert "Foo" not in unused_names
227+
228+ def test_mixed_default_and_type_only_import_marks_as_used (self , tmp_path ):
229+ """`import Default, { type Foo } from ...` should mark Foo as used."""
230+ mod = tmp_path / "mod.ts"
231+ mod .write_text ('export default function Default() { return 1; }\n export type Foo = string;\n ' )
232+ app = tmp_path / "app.ts"
233+ app .write_text ('import Default, { type Foo } from "./mod";\n const x: Foo = "hi";\n ' )
234+
235+ scanner = DeadCodeScanner (tmp_path )
236+ result = scanner .scan ()
237+
238+ unused_names = {f .name for f in result .unused_exports }
239+ assert "Default" not in unused_names
240+ assert "Foo" not in unused_names
241+
215242
216243class TestCSSParsing :
217244 def test_orphaned_css_detection (self , tmp_path ):
0 commit comments