File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -315,7 +315,7 @@ namespace ts {
315315 }
316316
317317 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 ) ) ;
319319 }
320320
321321 /**
@@ -383,8 +383,8 @@ namespace ts {
383383 symbolTable . set ( name , symbol = createSymbol ( SymbolFlags . None , name ) ) ;
384384 }
385385 else {
386- if ( ( node as NamedDeclaration ) . name ) {
387- ( node as NamedDeclaration ) . name . parent = node ;
386+ if ( isNamedDeclaration ( node ) ) {
387+ node . name . parent = node ;
388388 }
389389
390390 // Report errors every position with duplicate declaration
Original file line number Diff line number Diff line change @@ -4250,6 +4250,11 @@ namespace ts {
42504250 return declaration . name || nameForNamelessJSDocTypedef ( declaration ) ;
42514251 }
42524252
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+
42534258 export function getNameOfDeclaration ( declaration : Declaration | Expression ) : DeclarationName | undefined {
42544259 if ( ! declaration ) {
42554260 return undefined ;
You can’t perform that action at this time.
0 commit comments