Repository navigation
Description
TypeScript: an import(...) type used as an explicit type argument is a syntax error, dropping symbols after it
Summary
In .ts and .tsx, a call with an explicit type argument that is an import type —
f<typeof import("mod")>() or f<import("mod").Foo>() — is reported as a syntax
error, and the symbols declared after it are not extracted.
The same import type is fine in a type alias or a type annotation. Only the
type-argument position of a call expression fails.
Reproduction (graphify 0.9.51, Linux)
src/fails.tsx
const a = load<typeof import("react-router")>()
export function used() { return 1 }
export function alsoUsed() { return 2 }
export class Thing {}src/works.tsx — identical except the type argument
const a = load<string>()
export function used() { return 1 }
export function alsoUsed() { return 2 }
export class Thing {}$ graphify update . --force --no-cluster
warning: 1 file(s) had syntax errors and may be partially extracted:
src/fails.tsx (first error at line 1, 3 symbol(s) extracted)
Nodes per file in the resulting graph.json:
| file | nodes |
|---|---|
src/works.tsx |
5 |
src/fails.tsx |
3 |
used, alsoUsed and Thing are declared identically in both files, but two of
them are missing from fails.tsx.
What does and does not trigger it
| form | result |
|---|---|
f<typeof import("mod")>() |
❌ syntax error (.ts and .tsx) |
f<import("mod").Foo>() |
❌ syntax error |
f<string>() |
✅ fine |
f<typeof window>() |
✅ fine |
type T = typeof import("mod") |
✅ fine |
let a: typeof import("mod") |
✅ fine |
So it is not about import types in general, and not about explicit type arguments
in general — it is the combination.
It is not TSX-specific: the same line in a .ts file fails identically. It is
also unrelated to the file name (a double extension such as foo.vitest.tsx
parses fine on its own).
Why it matters in practice
This is the standard shape Vitest documents for partial module mocks:
vi.mock("react-router", async importOriginal => {
const actual = await importOriginal<typeof import("react-router")>()
return { ...actual, Meta: () => null }
})Because vi.mock calls are hoisted to the top of the file, the error lands on an
early line and most of the file's symbols are lost. In one private repository,
22 of 41 component test files are affected, some losing everything after line 1.
Environment
- graphify 0.9.51 (installed via
uv tool install "graphifyy[sql,terraform]==0.9.51") - Linux, Python 3.13
- Reproduced with a fresh
graphify update . --force --no-clusteron a directory
containing only the two files above
Note
The extractor does report the problem in a warning, which made it easy to find —
thank you. The issue is that the recovery drops the remaining declarations rather
than resuming after the offending expression.
Activity
safishamsi commentedon Aug 29, 2026
Fixed in v0.9.52: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.52. Closing as resolved.