π Search Terms
api, getCompletionsAtPosition
π Version & Regression Information
getCompletionsAtPosition was added in microsoft/typescript-go@4a461b7 (7.0.2)
β― 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
// export.ts
export const someValue = 1
// index.ts
someV
// repro.mjs
import path from 'node:path'
import { API } from 'typescript/unstable/sync'
const api = new API()
const root = process.cwd()
const file = path.join(root, 'index.ts')
const tsconfigPath = path.join(root, 'tsconfig.json')
const snapshot = api.updateSnapshot({ openProject: tsconfigPath })
const project = snapshot.getProject(tsconfigPath)
console.log(project.checker.getCompletionsAtPosition(file, 5))
- Run repro
π Actual behavior
file:///private/tmp/tsgo-auto-import-repro/node_modules/typescript/dist/api/syncChannel.js:237
throw new Error(this._msgPayload.toString("utf-8"));
^
Error: completion list needs auto imports
at SyncRpcChannel.requestBytesSync (file:///private/tmp/tsgo-auto-import-repro/node_modules/typescript/dist/api/syncChannel.js:237:31)
at SyncRpcChannel.requestSync (file:///private/tmp/tsgo-auto-import-repro/node_modules/typescript/dist/api/syncChannel.js:164:29)
at Client.apiRequest (file:///private/tmp/tsgo-auto-import-repro/node_modules/typescript/dist/api/sync/client.js:58:37)
at Checker.getCompletionsAtPosition (file:///private/tmp/tsgo-auto-import-repro/node_modules/typescript/dist/api/sync/api.js:723:34)
at file:///private/tmp/tsgo-auto-import-repro/repro.mjs:11: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
It should return completions instead of throwing.
Additional information about the issue
No response
π Search Terms
api, getCompletionsAtPosition
π Version & Regression Information
getCompletionsAtPositionwas added in microsoft/typescript-go@4a461b7 (7.0.2)β― Playground Link
No response
π» Code
π Actual behavior
π Expected behavior
It should return completions instead of throwing.
Additional information about the issue
No response