microsoft/typescript-go

textDocument/completion Could not find symbol

Opened this issue · 2 comments

This panicked while I was typing out a new test case.


panic handling request textDocument/completion Could not find symbol 'sourceMapsEnabled' by key 'sourceMapsEnabled' in module "/home/jabaile/.cache/typescript/7.0/node_modules/@types/graceful-fs/index" goroutine 2147 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x5e
github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(0xc0000f8dc0, 0xc00d1abd70)
	github.com/microsoft/typescript-go/internal/lsp/server.go:532 +0x58
panic({0xae6b60?, 0xc00f93e140?})
	runtime/panic.go:783 +0x132
github.com/microsoft/typescript-go/internal/ls.(*exportInfoMap).rehydrateCachedInfo(0xc000329090, 0xc0015c2c08, {0x1, {0xc006a77e4c, 0x11}, {0xc006a77e4c, 0x11}, {0x0, 0x0}, {0xc00027e161, ...}, ...})
	github.com/microsoft/typescript-go/internal/ls/autoimports.go:302 +0x494
github.com/microsoft/typescript-go/internal/ls.(*exportInfoMap).search.func1(...)
	github.com/microsoft/typescript-go/internal/ls/autoimports.go:231
github.com/microsoft/typescript-go/internal/core.Map[...](...)
	github.com/microsoft/typescript-go/internal/core/core.go:57
github.com/microsoft/typescript-go/internal/ls.(*exportInfoMap).search(0xc000329090, 0xc0015c2c08, {0xc0002401e7?, 0x47769f?}, 0x0, 0xc0003291f8, 0xc000329338)
	github.com/microsoft/typescript-go/internal/ls/autoimports.go:230 +0x3d4
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).searchExportInfosForCompletions(0xc00e564de0, {0xe66270, 0xc0094bb9f0}, 0xc0015c2c08, 0xc00946b608, 0xc00e604090, 0x0, 0x0, 0x0, {0xe885c8, ...}, ...)
	github.com/microsoft/typescript-go/internal/ls/autoimportsexportinfo.go:172 +0x3da
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData.func9()
	github.com/microsoft/typescript-go/internal/ls/completions.go:1269 +0x26c
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData.func17()
	github.com/microsoft/typescript-go/internal/ls/completions.go:1685 +0x5f6
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData.func18(...)
	github.com/microsoft/typescript-go/internal/ls/completions.go:1712
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData(0xc00e564de0, {0xe66270, 0xc0094bb9f0}, 0xc0015c2c08, 0xc00946b608, 0x1, 0xc00e604090)
	github.com/microsoft/typescript-go/internal/ls/completions.go:1740 +0x1ee2
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionsAtPosition(0xc00e564de0, {0xe66270, 0xc0094bb9f0}, 0xc00946b608, 0x1, 0x0, 0xc00e604090, 0xc00026d2c0)
	github.com/microsoft/typescript-go/internal/ls/completions.go:397 +0x2dd
github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideCompletion(0xc00e564de0, {0xe66270, 0xc0094bb9f0}, {0xc00b59bda0?, 0x1?}, {0x1?, 0x0?}, 0xc00d141210, 0xc00026d2c0, 0xc00e604090)
	github.com/microsoft/typescript-go/internal/ls/completions.go:48 +0xe7
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleCompletion(0xc0003581c0?, {0xe66270, 0xc0094bb9f0}, 0xc00e564de0, 0xc00d1abd40)
	github.com/microsoft/typescript-go/internal/lsp/server.go:754 +0xff
github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].15({0xe66270, 0xc0094bb9f0}, 0xc00d1abd70)
	github.com/microsoft/typescript-go/internal/lsp/server.go:518 +0x130
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0xc0000f8dc0, {0xe66270, 0xc0094bb9f0}, 0xc00d1abd70)
	github.com/microsoft/typescript-go/internal/lsp/server.go:424 +0x10d
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
	github.com/microsoft/typescript-go/internal/lsp/server.go:329 +0x3a
created by github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop in goroutine 35
	github.com/microsoft/typescript-go/internal/lsp/server.go:349 +0x8aa

[Error - 10:14:47 AM] Request textDocument/completion failed.
  Message: InternalError: panic handling request textDocument/completion: Could not find symbol 'sourceMapsEnabled' by key 'sourceMapsEnabled' in module "/home/jabaile/.cache/typescript/7.0/node_modules/@types/graceful-fs/index"
  Code: -32603 
[10:14:47.980] Processed 1 file changes in 30.405µs
======== Cloning snapshot 8 ========
[10:14:47.980] Reason: RequestedLanguageService (pending file changes) - [file:///home/jabaile/work/TypeScript-go/testdata/tests/cases/compiler/tsgo1701.ts]
[10:14:47.980] DidChangeFiles
	[10:14:47.980] Checking for changes affecting config files
		[10:14:47.980] Summarizing file changes
		[10:14:47.980] Checking if any changed files are config files
	[10:14:47.980] Marking project /dev/null/inferred as dirty due to changes in /home/jabaile/work/TypeScript-go/testdata/tests/cases/compiler/tsgo1701.ts
[10:14:47.980] DidRequestFile
	[10:14:47.980] CompilerHost
	[10:14:47.981] Program update for /dev/null/inferred completed in 321.044µs
[10:14:47.981] Finished cloning snapshot 8 into snapshot 9 in 350.748µs

Same, here’s my repro. In the TS repo, add a new .ts file in tests/cases/conformance/moduleResolution and paste:

// @module: esnext
// @moduleResolution: node16,nodenext,bundler
// @traceResolution: true
// @allowJs: true
// @noTypesAndSymbols: true
// @noEmit: true

// We fixed https://github.com/microsoft/TypeScript/issues/50762 for `null` only

// @Filename: /node_modules/dep/package.json
{
  "name": "dep",
  "version": "1.0.0",
  "exports": {
    ".": {
        "import": null,
        "require": "./dist/index.js",
        "types": "./dist/index.d.ts"
    }
  }
}

// @Filename: /node_modules/dep/dist/index.d.ts
export {};

// @Filename: /node_modules/dep/dist/index.mjs
export {};

// @Filename: /index.mts
import {} from "dep";
// Should be an untyped resolution to dep/dist/index.mjs,
// but the first search is only for TS files, and when
// there's no dist/index.d.mts, it continues looking for
// matching conditions and resolves via `types`.

Put the cursor at the end of null in "import": null, and press ctrl+space

I think #1844 is on this one even though it didn't link back.