Skip to content

Commit

Permalink
fix: definition request crashing on getting span (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl committed Aug 25, 2022
1 parent f1b5270 commit 4e1c82b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lsp-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,8 @@ export class LspServer {
if (response.type !== 'response' || !response.body) {
return undefined;
}
const span = Range.fromTextSpan(response.body.textSpan);
// `textSpan` can be undefined in older TypeScript versions, despite type saying otherwise.
const span = response.body.textSpan ? Range.fromTextSpan(response.body.textSpan) : undefined;
return response.body.definitions
.map((location): lsp.DefinitionLink => {
const target = toLocation(location, this.documents);
Expand Down

0 comments on commit 4e1c82b

Please sign in to comment.