π Search Terms
api, getTypeAtLocation, number literal, infinity
π Version & Regression Information
Fails on the current main
β― Playground Link
No response
π» Code
- Create repro dir
mkdir /tmp/repro
cd /tmp/repro
npm init -y
npm add typescript@7.0.2
echo '{}' > tsconfig.json
- Create files
// index.ts
export type Foo = 1e999
// repro.mjs
import path from 'node:path'
import { API } from 'typescript/unstable/sync'
const api = new API()
const root = process.cwd()
const filepath = path.join(root, 'index.ts')
const tsconfigPath = path.join(root, 'tsconfig.json')
const snapshot = api.updateSnapshot({ openProject: tsconfigPath })
const project = snapshot.getProject(tsconfigPath)
const file = project.program.getSourceFile(filepath)
console.log(project.checker.getTypeAtLocation(file.statements[0].name).value)
- Run repro
π Actual behavior
> node repro.mjs
file:///private/tmp/repro/node_modules/typescript/dist/api/syncChannel.js:237
throw new Error(this._msgPayload.toString("utf-8"));
^
Error: panic: api: failed to write response: json: cannot marshal from Go float64 within "/value": unsupported value: +Inf
goroutine 1 [running]:
runtime/debug.Stack()
runtime/debug/stack.go:26 +0x64
github.com/microsoft/typescript-go/internal/api.(*SyncConn).handleRequest.func1()
github.com/microsoft/typescript-go/internal/api/conn_sync.go:120 +0x44
panic({0x105b7fd60?, 0x6312dfe23c00?})
runtime/panic.go:860 +0x12c
github.com/microsoft/typescript-go/internal/api.(*SyncConn).handleRequest(0x6312dfb08c40, {0x105e2a0b8, 0x6312dfb08b00}, 0x6312e15d9e00)
github.com/microsoft/typescript-go/internal/api/conn_sync.go:156 +0x5c0
github.com/microsoft/typescript-go/internal/api.(*SyncConn).Run(0x6312dfb08c40, {0x105e2a0b8, 0x6312dfb08b00})
github.com/microsoft/typescript-go/internal/api/conn_sync.go:73 +0x140
github.com/microsoft/typescript-go/internal/api.(*StdioServer).Run(0x6312dfb13dc8, {0x105e2a0b8, 0x6312dfb08b00})
github.com/microsoft/typescript-go/internal/api/server.go:123 +0x580
main.runAPI({0x6312df93c0e0, 0x2, 0x2})
github.com/microsoft/typescript-go/cmd/tsgo/api.go:56 +0x340
main.runMain()
github.com/microsoft/typescript-go/cmd/tsgo/main.go:25 +0xb8
main.main()
github.com/microsoft/typescript-go/cmd/tsgo/main.go:14 +0x1c
at SyncRpcChannel.requestBytesSync (file:///private/tmp/repro/node_modules/typescript/dist/api/syncChannel.js:237:31)
at SyncRpcChannel.requestSync (file:///private/tmp/repro/node_modules/typescript/dist/api/syncChannel.js:164:29)
at Client.apiRequest (file:///private/tmp/repro/node_modules/typescript/dist/api/sync/client.js:58:37)
at Checker.getTypeAtLocation (file:///private/tmp/repro/node_modules/typescript/dist/api/sync/api.js:750:34)
at file:///private/tmp/repro/repro.mjs:14:29
at ModuleJob.run (node:internal/modules/esm/module_job:439:25)
at async node:internal/modules/esm/loader:643:26
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5)
Node.js v24.18.0
π Expected behavior
.value is expected to be +Infinity
Additional information about the issue
No response
π Search Terms
api, getTypeAtLocation, number literal, infinity
π Version & Regression Information
Fails on the current
mainβ― Playground Link
No response
π» Code
π Actual behavior
π Expected behavior
.valueis expected to be+InfinityAdditional information about the issue
No response