`vue-tsc` and language server issues in combination with `allowJs: true`

#62 · closed · 1 comments

View on GitHub ↗

niksy

I have a large repository with JS files which I allow to be imported in TS files with `allowJs: true`. I’ve noticed that whenever that option is active, I can get errors in TS language server and when running `vue-tsc`. Unfortunately, I can’t provide full repository since it’s internal project, but it can consistently be reproduced by toggling that option. **`vue-tsc` error** ```sh npx vue-tsc npm notice run npx npm notice run 'vue-tsc' ▎ TNB ACTIVE — `typescript` is the tsgo-backed fork panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked] [signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x11fe40868] goroutine 5067 [running]: sync.(*WaitGroup).Go.func1.1() /Users/runner/hostedtoolcache/go/1.26.5/arm64/src/sync/waitgroup.go:251 +0x48 panic({0x120c68d40?, 0x120f08b70?}) /Users/runner/hostedtoolcache/go/1.26.5/arm64/src/runtime/panic.go:860 +0x12c github.com/microsoft/typescript-go/internal/ast.IsIdentifier(...) /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/ast/ast_generated.go:638 github.com/microsoft/typescript-go/internal/parser.(*Parser).checkNonIdentifierName(0x182126452010?, 0x18212e639770?) /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/parser/reparser.go:42 +0x18 github.com/microsoft/typescript-go/internal/parser.(*Parser).reparseJSDocSignature(0x182126452008, 0x18212e632fc0, 0x18212e601808, 0x18212e660380, 0x18212e6399a0, 0x0?) /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/parser/reparser.go:147 +0x13c github.com/microsoft/typescript-go/internal/parser.(*Parser).reparseUnhosted(0x182126452008, 0x18212e6399a0, 0x18212e601808, 0x18212e660380) /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/parser/reparser.go:137 +0xc0 github.com/microsoft/typescript-go/internal/parser.(*Parser).reparseTags(0x182126452008, 0x18212e601808, {0x18212df4f0e8, 0x3, 0x1ea?}) /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/parser/reparser.go:62 +0xe8 github.com/microsoft/typescript-go/internal/parser.(*Parser).withJSDoc(0x182126452008, 0x18212e601808, 0x0?) /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/parser/jsdoc.go:99 +0x27c github.com/microsoft/typescript-go/internal/parser.(*Parser).parseFunctionDeclaration(0x182126452008, 0xcc, 0x1, 0x18212e639770) /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/parser/parser.go:1735 +0x1f8 github.com/microsoft/typescript-go/internal/parser.(*Parser).parseDeclarationWorker(0x182126452008, 0xcc, 0x1, 0x18212e639770) /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/parser/parser.go:1161 +0xa0 github.com/microsoft/typescript-go/internal/parser.(*Parser).parseDeclaration(0x182126452008) /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/parser/parser.go:1148 +0x98 github.com/microsoft/typescript-go/internal/parser.(*Parser).parseStatement(0x182126452008) /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/parser/parser.go:1119 +0x50c github.com/microsoft/typescript-go/internal/parser.(*Parser).parseToplevelStatement(0x182126452008, 0x3) /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/parser/parser.go:503 +0x28 github.com/microsoft/typescript-go/internal/parser.(*Parser).parseListIndex(0x182126452008, 0x0, 0x120e6f760) /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/parser/parser.go:622 +0x12c github.com/microsoft/typescript-go/internal/parser.(*Parser).parseSourceFileWorker(0x182126452008) /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/parser/parser.go:436 +0x70 github.com/microsoft/typescript-go/internal/parser.ParseSourceFile({{0x1821290ff420, 0x6a}, {0x18212e645180, 0x6a}, {0x0, 0x1}}, {0x18212e666000, 0x53e}, 0x1) /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/parser/parser.go:145 +0xf0 main.BridgeNewSession.NewParseCache.func1({{{0x1821290ff420, 0x6a}, {0x18212e645180, 0x6a}, {0x0, 0x1}}, 0x1, {0x7b713acb756e0d66, 0x3815b751f2d5aefe}}, {0x120e7f900, ...}) /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/project/parsecache.go:34 +0x84 github.com/microsoft/typescript-go/internal/project.(*RefCountCache[...]).Acquire(0x1821290ff420, {{{0x1821290ff420?, 0x6a}, {0x18212e645180, 0x6a}, {0x0, 0x1}}, 0x1, {0x7b713acb756e0d66, 0x3815b751f2d5aefe}}, ...) /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/project/refcountcache.go:62 +0xc4 github.com/microsoft/typescript-go/internal/project.(*compilerHost).GetSourceFile(0x1821255c5e00, {{0x1821290ff420, 0x6a}, {0x18212e645180, 0x6a}, {0x0, 0x1}}) /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/project/compilerhost.go:113 +0x174 github.com/microsoft/typescript-go/internal/compiler.(*fileLoader).parseSourceFile(0x182125798608, 0x18212ca39860) /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/compiler/fileloader.go:382 +0x1b4 github.com/microsoft/typescript-go/internal/compiler.(*parseTask).load(0x18212ca39860, 0x182125798608) /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/compiler/filesparser.go:115 +0x3e0 github.com/microsoft/typescript-go/internal/compiler.(*filesParser).start.func1() /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/compiler/filesparser.go:296 +0x308 github.com/microsoft/typescript-go/internal/core.(*parallelWorkGroup).Queue.func1() /Users/runner/work/typescript-native-bridge/typescript-native-bridge/typescript-go/internal/core/workgroup.go:40 +0x24 sync.(*WaitGroup).Go.func1() /Users/runner/hostedtoolcache/go/1.26.5/arm64/src/sync/waitgroup.go:258 +0x48 created by sync.(*WaitGroup).Go in goroutine 4383 /Users/runner/hostedtoolcache/go/1.26.5/arm64/src/sync/waitgroup.go:238 +0x70 Abort trap: 6 ``` **TS server error** I’m using Sublime Text and LSP-typescript and error is visible only on Vue files. The same error is not visible when running on `.ts` files. ```sh LSP-typescript: file:///Users/niksy/Library/Caches/Sublime%20Text/Package%20Storage/LSP-typescript/typescript-language-server/node_modules/typescript-language-server/lib/cli.mjs:23886 LSP-typescript: throw new Error(`tsserver process has exited (exit code: ${exitCode}, signal: ${signal}). Stopping the server.`); LSP-typescript: ^ LSP-typescript: LSP-typescript: Error: tsserver process has exited (exit code: 1, signal: null). Stopping the server. LSP-typescript: at TsClient.onExit (file:///Users/niksy/Library/Caches/Sublime%20Text/Package%20Storage/LSP-typescript/typescript-language-server/node_modules/typescript-language-server/lib/cli.mjs:23886:17) LSP-typescript: at file:///Users/niksy/Library/Caches/Sublime%20Text/Package%20Storage/LSP-typescript/typescript-language-server/node_modules/typescript-language-server/lib/cli.mjs:19943:20 LSP-typescript: at file:///Users/niksy/Library/Caches/Sublime%20Text/Package%20Storage/LSP-typescript/typescript-language-server/node_modules/typescript-language-server/lib/cli.mjs:18641:45 LSP-typescript: at Set.forEach (<anonymous>) LSP-typescript: at file:///Users/niksy/Library/Caches/Sublime%20Text/Package%20Storage/LSP-typescript/typescript-language-server/node_modules/typescript-language-server/lib/cli.mjs:18641:26 LSP-typescript: at file:///Users/niksy/Library/Caches/Sublime%20Text/Package%20Storage/LSP-typescript/typescript-language-server/node_modules/typescript-language-server/lib/cli.mjs:18348:45 LSP-typescript: at Set.forEach (<anonymous>) LSP-typescript: at ChildProcess.<anonymous> (file:///Users/niksy/Library/Caches/Sublime%20Text/Package%20Storage/LSP-typescript/typescript-language-server/node_modules/typescript-language-server/lib/cli.mjs:18348:26) LSP-typescript: at ChildProcess.emit (node:events:514:20) LSP-typescript: at ChildProcess._handle.onexit (node:internal/child_process:294:12) ```

Comments

johnsoncodehk

Confirmed this is an upstream tsgo parser crash (`@overload` on an anonymous `export default function () {}` under `allowJs`), reproduced on a pristine tsgo checkout, and filed at microsoft/TypeScript#63750.