diff --git a/src/features/source-definition.ts b/src/features/source-definition.ts index 51a5df50..e1d4daa9 100644 --- a/src/features/source-definition.ts +++ b/src/features/source-definition.ts @@ -60,10 +60,11 @@ export class SourceDefinitionCommand { reporter, }, async () => { const response = await tspClient.request(CommandTypes.FindSourceDefinition, args); - if (response.type === 'response' && response.body?.length) { - return response.body.map(reference => toLocation(reference, documents)); + if (response.type !== 'response' || !response.body) { + lspClient.showErrorMessage('No source definitions found.'); + return; } - lspClient.showErrorMessage('No source definitions found.'); + return response.body.map(reference => toLocation(reference, documents)); }); } }