neoclide / coc-tsserver

Tsserver extension for coc.nvim that provide rich features like VSCode for javascript & typescript
MIT License
1.05k stars 68 forks source link

Strange error when creating method on class #365

Open otavioschwanck opened 2 years ago

otavioschwanck commented 2 years ago

log: https://pastebin.com/iXFUZ0HD output: https://pastebin.com/ijbLF1dq

Error:

[coc.nvim] Error: Error processing request. Debug Failure. False expression: Token end is child end
Error: Debug Failure. False expression: Token end is child end
    at processChildNode (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:144340:38)
    at /Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:144280:21
    at visitNode (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:29849:24)
    at Object.forEachChild (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:29927:21)
    at processNode (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:144279:20)
    at processChildNode (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:144347:21)
    at processChildNodes (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:144394:48)
    at /Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:144282:21
    at visitNodes (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:29854:24)
    at Object.forEachChild (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:29994:24)
    at processNode (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:144279:20)
    at processChildNode (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:144347:21)
    at processChildNodes (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:144394:48)
    at /Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:144282:21
    at visitNodes (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:29854:24)
    at Object.forEachChild (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:30001:24)
    at processNode (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:144279:20)
    at processChildNode (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:144347:21)
    at /Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:144280:21
    at visitNode (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:29849:24)
    at Object.forEachChild (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:29922:21)
    at processNode (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:144279:20)
    at formatSpanWorker (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:144080:17)
    at /Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:144044:140
    at Object.getFormattingScanner (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:142671:23)
    at Object.formatNodeGivenIndentation (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:144044:31)
    at /Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:129974:46
    at Object.flatMap (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:508:25)
    at getEntryForMemberCompletion (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:129972:38)
    at createCompletionEntry (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:129792:23)
    at getCompletionEntriesFromSymbols (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:130156:29)
    at completionInfoFromData (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:129610:17)
    at Object.getCompletionsAtPosition (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:129471:36)
    at Object.getCompletionsAtPosition (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:161872:35)
    at IOSession.Session.getCompletions (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:173420:64)
    at Session.handlers.ts.Map.ts.getEntries._a.<computed> (/Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:172262:61)
    at /Users/otavio/Projetos/nest-investment-front/node_modules/typescript/lib/tsserver.js:174069:88
g-m-a commented 2 years ago

any updates on this?

chemzqm commented 2 years ago

Seems you don't have proper tsconfig.json, should be issue of tsserver.

ewal commented 2 years ago

This problem appeared for me as well a couple of days ago after I updated my plugins, coc and plug. I've tried to disable all unnecessary vim plugins and replaced the tsconfig file with base confs from https://github.com/tsconfig/bases, but with no success. Any suggestions on how to continue debugging the issue?

chemzqm commented 2 years ago

@ewal Create a minimal file, reproduce the issue, and upload the verbose output from coc-tsserver, so we could inspect what happened.

chemzqm commented 2 years ago

I've checked the log of tsserver, seems all request working as expected, no idea why the error happens.

ewal commented 2 years ago

Thank you for the reply. Worth noting is that error is only thrown on extended classes. Thinking it could be related to the imported package of course, but it is happening in several different TypeScript projects I'm working on.


Info 83   [20:24:41.001] Starting updateGraphWorker: Project: /Users/***/projects/tsdebug/tsconfig.json
Info 84   [20:24:41.006] Finishing updateGraphWorker: Project: /Users/***/projects/tsdebug/tsconfig.json Version: 3 structureChanged: false structureIsReused:: Completely Elapsed: 4.937875002622604ms
Info 85   [20:24:41.006] Different program with same set of files
Info 86   [20:24:41.022] getCompletionData: Get current token: 0.014917001128196716
Info 87   [20:24:41.022] getCompletionData: Is inside comment: 0.022707998752593994
Info 88   [20:24:41.022] getCompletionData: Get previous token: 0.06837499141693115
Info 89   [20:24:41.023] getCompletionsAtPosition: isCompletionListBlocker: 0.13316699862480164
Info 90   [20:24:41.027] getCompletionData: Semantic work: 3.933583989739418
Err 91    [20:24:41.059] Exception on executing command {"seq":9,"type":"request","command":"completionInfo","arguments":{"file":"/Users/***/projects/tsdebug/src/main.ts","line":4,"offset":4,"includeExternalModuleExports":true,"includeInsertTextCompletions":true,"includeAutomaticOptionalChainCompletions":true}}:

    Debug Failure. Did not expect GetAccessor to have an Identifier in its trivia

    Error: Debug Failure. Did not expect GetAccessor to have an Identifier in its trivia
        at addSyntheticNodes (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:163351:30)
        at processNode (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:163324:13)
        at visitNode (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:30463:24)
        at Object.forEachChild (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:30617:21)
        at NodeObject.forEachChild (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:163305:23)
        at createChildren (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:163339:14)
        at NodeObject.getChildren (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:163282:56)
        at find (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:126886:30)
        at Object.findPrecedingToken (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:126879:22)
        at formatSpanWorker (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:146596:44)
        at /Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:146540:140
        at Object.getFormattingScanner (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:145167:23)
        at Object.formatNodeGivenIndentation (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:146540:31)
        at /Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:132204:42
        at Object.flatMap (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:508:25)
        at Object.printAndFormatSnippetList (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:132202:34)
        at getEntryForMemberCompletion (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:132004:42)
        at createCompletionEntry (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:131824:23)
        at getCompletionEntriesFromSymbols (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:132331:29)
        at completionInfoFromData (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:131640:17)
        at Object.getCompletionsAtPosition (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:131495:36)
        at Object.getCompletionsAtPosition (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:164577:35)
        at IOSession.Session.getCompletions (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:176377:64)
        at Session.handlers.ts.Map.ts.getEntries._a.<computed> (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:175052:61)
        at /Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:177109:88
        at IOSession.Session.executeWithRequestId (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:177100:28)
        at IOSession.Session.executeCommand (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:177109:33)
        at IOSession.Session.onMessage (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:177135:35)
        at Interface.<anonymous> (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:179740:31)
        at Interface.emit (node:events:526:28)
        at Interface._onLine (node:readline:487:10)
        at Interface._normalWrite (node:readline:661:12)
        at Socket.ondata (node:readline:269:10)
        at Socket.emit (node:events:526:28)
        at addChunk (node:internal/streams/readable:315:12)
        at readableAddChunk (node:internal/streams/readable:289:9)
        at Socket.Readable.push (node:internal/streams/readable:228:10)
        at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)

File text of /Users/***/projects/tsdebug/src/main.ts:
    import * as ex from "excalibur";

    class ChildClass extends ex.Actor {
      g
    }

Info 92   [20:24:41.059] response:
    {"seq":0,"type":"response","command":"completionInfo","request_seq":9,"success":false,"performanceData":{"updateGraphDurationMs":4.937875002622604},"message":"Error processing request. Debug Failure. Did not expect GetAccessor to have an Identifier in its trivia\nError: Debug Failure. Did not expect GetAccessor to have an Identifier in its trivia\n    at addSyntheticNodes (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:163351:30)\n    at processNode (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:163324:13)\n    at visitNode (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:30463:24)\n    at Object.forEachChild (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:30617:21)\n    at NodeObject.forEachChild (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:163305:23)\n    at createChildren (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:163339:14)\n    at NodeObject.getChildren (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:163282:56)\n    at find (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:126886:30)\n    at Object.findPrecedingToken (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:126879:22)\n    at formatSpanWorker (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:146596:44)\n    at /Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:146540:140\n    at Object.getFormattingScanner (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:145167:23)\n    at Object.formatNodeGivenIndentation (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:146540:31)\n    at /Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:132204:42\n    at Object.flatMap (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:508:25)\n    at Object.printAndFormatSnippetList (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:132202:34)\n    at getEntryForMemberCompletion (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:132004:42)\n    at createCompletionEntry (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:131824:23)\n    at getCompletionEntriesFromSymbols (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:132331:29)\n    at completionInfoFromData (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:131640:17)\n    at Object.getCompletionsAtPosition (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:131495:36)\n    at Object.getCompletionsAtPosition (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:164577:35)\n    at IOSession.Session.getCompletions (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:176377:64)\n    at Session.handlers.ts.Map.ts.getEntries._a.<computed> (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:175052:61)\n    at /Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:177109:88\n    at IOSession.Session.executeWithRequestId (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:177100:28)\n    at IOSession.Session.executeCommand (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:177109:33)\n    at IOSession.Session.onMessage (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:177135:35)\n    at Interface.<anonymous> (/Users/***/.config/coc/extensions/node_modules/coc-tsserver/node_modules/typescript/lib/tsserver.js:179740:31)\n    at Interface.emit (node:events:526:28)\n    at Interface._onLine (node:readline:487:10)\n    at Interface._normalWrite (node:readline:661:12)\n    at Socket.ondata (node:readline:269:10)\n    at Socket.emit (node:events:526:28)\n    at addChunk (node:internal/streams/readable:315:12)\n    at readableAddChunk (node:internal/streams/readable:289:9)\n    at Socket.Readable.push (node:internal/streams/readable:228:10)\n    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)"}
Info 93   [20:24:41.297] request:
    {"seq":10,"type":"request","command":"geterr","arguments":{"delay":0,"files":["/Users/***/projects/tsdebug/src/main.ts"]}}
Perf 94   [20:24:41.297] 10::geterr: async elapsed time (in milliseconds) 0.5587
Info 95   [20:24:41.299] event:
    {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/Users/***/projects/tsdebug/src/main.ts","diagnostics":[]}}
Info 96   [20:24:41.305] event:
    {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/Users/***/projects/tsdebug/src/main.ts","diagnostics":[{"start":{"line":4,"offset":3},"end":{"line":4,"offset":4},"text":"Member 'g' implicitly has an 'any' type.","code":7008,"category":"error"}]}}
Info 97   [20:24:41.306] event:
    {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/Users/***/projects/tsdebug/src/main.ts","diagnostics":[{"start":{"line":3,"offset":7},"end":{"line":3,"offset":12},"text":"'Child' is declared but never used.","code":6196,"category":"suggestion","reportsUnnecessary":true}]}}
Info 98   [20:24:41.306] event:
    {"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":10}}
ewal commented 2 years ago

Update: I uninstalled coc-tsserver and configured typescript-language-server manually and it works without problems 🤷

chemzqm commented 2 years ago

Don't know, can't reproduce the issue.

ewal commented 2 years ago

Ok, I give up now since I got it working without the tsserver throwing errors.

If anyone else is stuck in the same situation you can solve it by uninstalling coc-tsserver, then install typescript and typescript-language-server globally and finally add the following to your coc config file:

  "languageserver": {
     "typescript-language-server": {
       "command": "typescript-language-server",
       "args": ["--stdio"],
       "filetypes": ["typescript", "javascript", "typescriptreact", "javascriptreact"]
     }
  }
ewal commented 2 years ago

@chemzqm, was too stubborn to give up and found what's causing the error to be thrown. After digging through the source code of a library that I use I noticed a naming convention on their observable methods which they had suffixed with a dollar sign, like such:

  public componentRemoved$ = new Observable<RemovedComponent>();

I removed all dollar signs from the code and the error is gone.

After googling some more I found the following in the Angular docs:

“… you will often see observables named with a trailing “$” sign. This can be useful when scanning through code and looking for observable values …”

Guess it must be an issue in coc-tsserver since using typescript-language-server works well.

This is the error message: [coc.nvim] Error: Error processing request. Debug Failure. False expression: Token end is child end Error: Debug Failure. False expression: Token end is child end

chemzqm commented 2 years ago

Should be issue with tsserver, coc-tsserver doesn't analysis your code.

ewal commented 2 years ago

You are right, @chemzqm. The dependency library I use was built using TypeScript 4.6.3. I forked and bumped the version to 4.7.3 and the problem disappeared.

Sorry @otavioschwanck for hijacking your post.

MuhammadSawalhy commented 2 years ago

Debug Failure. Did not expect GetAccessor to have an Identifier in its trivia

I got a strange error as well. Hope this will provide any hint to identify the problem. I was just coding some React.js components in .js files and I'm not using TypeScript anywhere in my code or any tsconfig.js file.

image