@@ -273,18 +273,21 @@ namespace ts.GoToDefinition {
273
273
function createDefinitionInfoFromName ( declaration : Declaration , symbolKind : ScriptElementKind , symbolName : string , containerName : string ) : DefinitionInfo {
274
274
const name = getNameOfDeclaration ( declaration ) || declaration ;
275
275
const sourceFile = name . getSourceFile ( ) ;
276
- const declarationNode = FindAllReferences . getDeclarationForDeclarationSpan ( declaration ) ! ;
277
- return {
276
+ const result : DefinitionInfo = {
278
277
fileName : sourceFile . fileName ,
279
278
textSpan : createTextSpanFromNode ( name , sourceFile ) ,
280
279
kind : symbolKind ,
281
280
name : symbolName ,
282
281
containerKind : undefined ! , // TODO: GH#18217
283
282
containerName,
284
- declarationSpan : FindAllReferences . isDeclarationNodeWithStartAndEnd ( declarationNode ) ?
285
- createTextSpanFromNode ( declarationNode . start , sourceFile , declarationNode . end ) :
286
- createTextSpanFromNode ( declarationNode , sourceFile ) ,
287
283
} ;
284
+ const declarationNode = FindAllReferences . getDeclarationForDeclarationSpan ( declaration ) ;
285
+ if ( declarationNode ) {
286
+ result . declarationSpan = FindAllReferences . isDeclarationNodeWithStartAndEnd ( declarationNode ) ?
287
+ createTextSpanFromNode ( declarationNode . start , sourceFile , declarationNode . end ) :
288
+ createTextSpanFromNode ( declarationNode , sourceFile ) ;
289
+ }
290
+ return result ;
288
291
}
289
292
290
293
function createDefinitionFromSignatureDeclaration ( typeChecker : TypeChecker , decl : SignatureDeclaration ) : DefinitionInfo {
0 commit comments