Skip to content

TypeError: Cannot read property 'parent' of undefined at isTypeAssertion #38407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
minestarks opened this issue May 7, 2020 · 2 comments · Fixed by #39347
Closed

TypeError: Cannot read property 'parent' of undefined at isTypeAssertion #38407

minestarks opened this issue May 7, 2020 · 2 comments · Fixed by #39347
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@minestarks
Copy link
Member

Repo Name: https://github.com/caolan/async.git

Revision: 62cb8ea8ce3e3b4b66cf9abc66153d2d7255985b

TypeScript Version: 4.0.0-dev.20200507

Commands:

{"response":[],"responseRequired":true}
{"command":"quickinfo-full","arguments":{"position":2047,"file":"D:/local/Temp/fuzzerWorkingDir/async/lib/cargoQueue.js"},"type":"request","seq":42}
{"responseRequired":true}
{"command":"quickinfo-full","arguments":{"position":1071,"file":"D:/local/Temp/fuzzerWorkingDir/async/lib/cargoQueue.js"},"type":"request","seq":42}
{"responseRequired":true}
{"command":"references-full","arguments":{"position":2047,"file":"D:/local/Temp/fuzzerWorkingDir/async/lib/cargoQueue.js"},"type":"request","seq":42}
{"response":[],"responseRequired":true}
{"command":"references-full","arguments":{"position":1071,"file":"D:/local/Temp/fuzzerWorkingDir/async/lib/cargoQueue.js"},"type":"request","seq":42}
{"response":[],"responseRequired":true}
{"command":"completions-full","arguments":{"position":2047,"file":"D:/local/Temp/fuzzerWorkingDir/async/lib/cargoQueue.js","includeExternalModuleExports":true,"includeInsertTextCompletions":true},"type":"request","seq":42}
(Showing last 10 of 191 commands)

Code (lib\cargoQueue.js):

   * how many tasks should be processed per round; if omitted, the default is
   * unlimited.
   * @returns {module:ControlFlow.QueueObject} A cargoQueue object to manage the tasks. Callbacks can
//                  ^
   * attached as certain properties to listen for specific events during the
   * lifecycle of the cargoQueue and inner queue.

Hash: dced6931d2c4b2cbd849ed76ef152cea
Stack trace:

TypeError: Cannot read property 'parent' of undefined
    at isTypeAssertion (D:\home\site\wwwroot\node_modules\typescript\lib\tsserverlibrary.js:113858:62)
    at filterGlobalCompletion (D:\home\site\wwwroot\node_modules\typescript\lib\tsserverlibrary.js:113833:38)
    at getGlobalCompletions (D:\home\site\wwwroot\node_modules\typescript\lib\tsserverlibrary.js:113804:17)
    at tryGetGlobalSymbols (D:\home\site\wwwroot\node_modules\typescript\lib\tsserverlibrary.js:113695:25)
    at getCompletionData (D:\home\site\wwwroot\node_modules\typescript\lib\tsserverlibrary.js:113489:22)
    at Object.getCompletionsAtPosition (D:\home\site\wwwroot\node_modules\typescript\lib\tsserverlibrary.js:112833:34)
    at Object.getCompletionsAtPosition (D:\home\site\wwwroot\node_modules\typescript\lib\tsserverlibrary.js:139693:35)
    at Session.getCompletions (D:\home\site\wwwroot\node_modules\typescript\lib\tsserverlibrary.js:149397:64)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (D:\home\site\wwwroot\node_modules\typescript\lib\tsserverlibrary.js:148340:61)
    at D:\home\site\wwwroot\node_modules\typescript\lib\tsserverlibrary.js:149974:88

Originally posted by @typescript-bot in https://github.com/microsoft/tsserverfuzzer/issues/227#issuecomment-625379845

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label May 8, 2020
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 4.0 milestone May 8, 2020
@sandersn
Copy link
Member

Couple of notes from early investigation:

  1. Our code base has two isTypeAssertions. This is the one in services/completions.ts.
  2. The variable that is undefined has the following comment before it:
        // The decision to provide completion depends on the contextToken, which is determined through the previousToken.
        // Note: 'previousToken' (and thus 'contextToken') can be undefined if we are the beginning of the file
        let contextToken = previousToken;

The comment says contextToken can sometimes be undefined even though its type does not contain undefined. Admittedly, this isn't at the beginning of file.

@sandersn
Copy link
Member

Repros in a standalone file with

/**
 * @returns {module:ControlFlow}
 */
export function cargo() {
}

Repros in Code but not emacs so far. Maybe emacs isn't sending completions-full?

@sandersn sandersn added the Fix Available A PR has been opened for this issue label Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants