Session: don't return undefined if a response is required - #17165
Conversation
| const definitions = project.getLanguageService().getDefinitionAtPosition(file, position); | ||
| if (!definitions) { | ||
| return undefined; | ||
| return []; |
There was a problem hiding this comment.
Are these results mutable? Can we use a shared emptyArray construct?
| } | ||
|
|
||
| private getFileAndProject(args: protocol.FileRequestArgs, errorOnMissingProject = true) { | ||
| private getFileAndProject(args: protocol.FileRequestArgs, errorOnMissingProject = true): { file: NormalizedPath, project: Project } { |
There was a problem hiding this comment.
Do we need the return type defined here, since it is correctly inferred?
|
Looks like the build is failing. Can you take a look? |
|
Fix is #17685, will merge once that's in |
|
Ron Buckton (@rbuckton) Build is passing now, good to go? |
…17165) * Session: don't return undefined if a response is required * Use ReadonlyArray and emptyArray * Remove inferred return type
| return { | ||
| info: renameInfo, | ||
| locs: [] | ||
| locs: emptyArray |
There was a problem hiding this comment.
Missed one on line 812?
| if (simplifiedResult) { | ||
| const nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position); | ||
| if (!nameInfo) { | ||
| return undefined; |
There was a problem hiding this comment.
Might break deserialization.
|
|
||
| const completions = project.getLanguageService().getCompletionsAtPosition(file, position); | ||
| if (!completions) { | ||
| return undefined; |
There was a problem hiding this comment.
Might break deserialization.
| } | ||
|
|
||
| private getTypeDefinition(args: protocol.FileLocationRequestArgs): protocol.FileSpan[] { | ||
| private getTypeDefinition(args: protocol.FileLocationRequestArgs): ReadonlyArray<protocol.FileSpan> { |
| } | ||
|
|
||
| private getDocumentHighlights(args: protocol.DocumentHighlightsRequestArgs, simplifiedResult: boolean): protocol.DocumentHighlightsItem[] | DocumentHighlights[] { | ||
| private getDocumentHighlights(args: protocol.DocumentHighlightsRequestArgs, simplifiedResult: boolean): ReadonlyArray<protocol.DocumentHighlightsItem> | ReadonlyArray<DocumentHighlights> { |
|
Andy (Andrewkraft) (@Andy-MS) It might be safest to revert this (and hold off on #17727) until we further discuss the implications for clients. (cc: Mine Starks (@minestarks), Ron Buckton (@rbuckton)) |
|
Might be better to wait for |
Sequel to #16773
This doesn't yet fix
SignatureHelp, since that doesn't return an array. I'm not sure if VSCode is depending on us sending back an "error" response if the user isn't currently at a signature.