File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -315,7 +315,7 @@ namespace ts {
315
315
}
316
316
317
317
function getDisplayName ( node : Declaration ) : string {
318
- return ( node as NamedDeclaration ) . name ? declarationNameToString ( ( node as NamedDeclaration ) . name ) : unescapeLeadingUnderscores ( getDeclarationName ( node ) ) ;
318
+ return isNamedDeclaration ( node ) ? declarationNameToString ( node . name ) : unescapeLeadingUnderscores ( getDeclarationName ( node ) ) ;
319
319
}
320
320
321
321
/**
@@ -383,8 +383,8 @@ namespace ts {
383
383
symbolTable . set ( name , symbol = createSymbol ( SymbolFlags . None , name ) ) ;
384
384
}
385
385
else {
386
- if ( ( node as NamedDeclaration ) . name ) {
387
- ( node as NamedDeclaration ) . name . parent = node ;
386
+ if ( isNamedDeclaration ( node ) ) {
387
+ node . name . parent = node ;
388
388
}
389
389
390
390
// Report errors every position with duplicate declaration
Original file line number Diff line number Diff line change @@ -4250,6 +4250,11 @@ namespace ts {
4250
4250
return declaration . name || nameForNamelessJSDocTypedef ( declaration ) ;
4251
4251
}
4252
4252
4253
+ /** @internal */
4254
+ export function isNamedDeclaration ( node : Node ) : node is NamedDeclaration & { name : DeclarationName } {
4255
+ return ! ! ( node as NamedDeclaration ) . name ; // A 'name' property should always be a DeclarationName.
4256
+ }
4257
+
4253
4258
export function getNameOfDeclaration ( declaration : Declaration | Expression ) : DeclarationName | undefined {
4254
4259
if ( ! declaration ) {
4255
4260
return undefined ;
You can’t perform that action at this time.
0 commit comments