You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the behavior in every version I tried: 7.1.0-dev.20260926.1 (panics in the Go checker) and 6.0.3 (throws TypeError: Cannot read properties of undefined (reading 'flags')). The unguarded branch looks like it dates back to Type-only imports and exports #35200, which added type-only ImportClause to isTypeDeclaration.
With TypeScript 6.0.3, getTypeAtLocation throws TypeError: Cannot read properties of undefined (reading 'flags').
The same happens for import type * as ns from "./types". A regular import { U } from "./types" clause does not crash.
🙂 Expected behavior
getTypeAtLocation returns a type (the error type, like it does for a regular import clause) instead of crashing.
Additional information about the issue
I'm building syscript, a compiler that compiles TypeScript syntax to C for systems programming. It walks every node of a program and requests its type through the TypeScript 7 API, and that walk crashed on the first file that used import type.
isTypeDeclaration returns true for a type-only ImportClause, but a clause only has a symbol when it has a default binding, so getTypeOfNode passes a nil symbol to getDeclaredTypeOfSymbol. I have a fix with a test ready and will open a PR referencing this issue.
🔎 Search Terms
getTypeAtLocation ImportClause, type-only import crash, import type getTypeAtLocation nil pointer, tryGetDeclaredTypeOfSymbol, getDeclaredTypeOfSymbol panic
🕗 Version & Regression Information
7.1.0-dev.20260926.1(panics in the Go checker) and6.0.3(throwsTypeError: Cannot read properties of undefined (reading 'flags')). The unguarded branch looks like it dates back to Type-only imports and exports #35200, which added type-onlyImportClausetoisTypeDeclaration.⏯ Playground Link
No response
💻 Code
🙁 Actual behavior
With TypeScript 7, the API server panics:
With TypeScript 6.0.3,
getTypeAtLocationthrowsTypeError: Cannot read properties of undefined (reading 'flags').The same happens for
import type * as ns from "./types". A regularimport { U } from "./types"clause does not crash.🙂 Expected behavior
getTypeAtLocationreturns a type (the error type, like it does for a regular import clause) instead of crashing.Additional information about the issue
I'm building syscript, a compiler that compiles TypeScript syntax to C for systems programming. It walks every node of a program and requests its type through the TypeScript 7 API, and that walk crashed on the first file that used
import type.isTypeDeclarationreturns true for a type-onlyImportClause, but a clause only has a symbol when it has a default binding, sogetTypeOfNodepasses a nil symbol togetDeclaredTypeOfSymbol. I have a fix with a test ready and will open a PR referencing this issue.