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
{{ message }}
This repository was archived by the owner on Sep 1, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 1, 2026. It is now read-only.
Extensionless root file panics the compiler: "ScriptKind must be specified when parsing source file" #4609
Any root file whose name has no extension crashes tsc 7 with a Go panic — reproducible from the CLI, a tsconfig, and the unstable API:
$ printf 'const n: number = "s";\n' > /tmp/script
$ tsc --ignoreConfig --noEmit /tmp/script
panic: ScriptKind must be specified when parsing source file: /tmp/script [recovered, repanicked]
goroutine 34 [running]:
...
github.com/microsoft/typescript-go/internal/parser.(*Parser).initializeState
github.com/microsoft/typescript-go/internal/parser/parser.go:292
github.com/microsoft/typescript-go/internal/parser.ParseSourceFile
github.com/microsoft/typescript-go/internal/parser/parser.go:140
github.com/microsoft/typescript-go/internal/compiler.(*compilerHost).GetSourceFile
github.com/microsoft/typescript-go/internal/compiler/host.go:83
Same panic from a tsconfig with "files": ["script"], and from the unstable API via updateSnapshot({ openFiles: ["/tmp/script"] }) — the API form goes through the project path instead (project.NewSession.NewParseCache → parsecache.go:34 → project/compilerhost.go:100).
Reproduces on 7.0.2 and on 7.1.0-dev.20260711.1.
TypeScript 6.0 rejects the same inputs gracefully:
error TS6231: Could not resolve the path '/tmp/script' with the extensions: '.ts', '.tsx', ...
The extensionless name gives GetScriptKindFromFileName nothing to go on, and the resulting Unknown kind reaches the parser assert (whose message #1556 improved) instead of being rejected or defaulted earlier.
Possibly related to #4267 — the stack there matches the project-path variant above, so an extensionless (or otherwise unrecognized) file in the workspace may be its missing repro. #4180 was the same assert reached via an unrecognized LSP languageId.
Context: we type-check extensionless #!-interpreter scripts (TS 6 handles them via a custom compiler host with an explicit ScriptKind), which is how we hit this while probing TS 7.
Activity