@@ -14,25 +14,25 @@ namespace ts.NavigationBar {
14
14
indent : number ; // # of parents
15
15
}
16
16
17
- export function getNavigationBarItems ( sourceFile_ : SourceFile ) : NavigationBarItem [ ] {
18
- sourceFile = sourceFile_ ;
17
+ export function getNavigationBarItems ( sourceFile : SourceFile ) : NavigationBarItem [ ] {
18
+ curSourceFile = sourceFile ;
19
19
const result = map ( topLevelItems ( rootNavigationBarNode ( sourceFile ) ) , convertToTopLevelItem ) ;
20
- sourceFile = void 0 ;
20
+ curSourceFile = undefined ;
21
21
return result ;
22
22
}
23
23
24
24
// Keep sourceFile handy so we don't have to search for it every time we need to call `getText`.
25
- let sourceFile : SourceFile ;
25
+ let curSourceFile : SourceFile ;
26
26
function nodeText ( node : Node ) : string {
27
- return node . getText ( sourceFile ) ;
27
+ return node . getText ( curSourceFile ) ;
28
28
}
29
29
30
30
function navigationBarNodeKind ( n : NavigationBarNode ) : SyntaxKind {
31
31
return n . node . kind ;
32
32
}
33
33
34
34
function pushChild ( parent : NavigationBarNode , child : NavigationBarNode ) : void {
35
- if ( parent . children !== void 0 ) {
35
+ if ( parent . children ) {
36
36
parent . children . push ( child ) ;
37
37
}
38
38
else {
@@ -50,13 +50,13 @@ namespace ts.NavigationBar {
50
50
51
51
function rootNavigationBarNode ( sourceFile : SourceFile ) : NavigationBarNode {
52
52
Debug . assert ( ! parentsStack . length ) ;
53
- const root : NavigationBarNode = { node : sourceFile , additionalNodes : void 0 , parent : void 0 , children : void 0 , indent : 0 } ;
53
+ const root : NavigationBarNode = { node : sourceFile , additionalNodes : undefined , parent : undefined , children : undefined , indent : 0 } ;
54
54
parent = root ;
55
55
for ( const statement of sourceFile . statements ) {
56
56
addChildrenRecursively ( statement ) ;
57
57
}
58
58
endNode ( ) ;
59
- Debug . assert ( parent === void 0 && ! parentsStack . length ) ;
59
+ Debug . assert ( ! parent && ! parentsStack . length ) ;
60
60
return root ;
61
61
}
62
62
@@ -67,9 +67,9 @@ namespace ts.NavigationBar {
67
67
function emptyNavigationBarNode ( node : Node ) : NavigationBarNode {
68
68
return {
69
69
node,
70
- additionalNodes : void 0 ,
70
+ additionalNodes : undefined ,
71
71
parent,
72
- children : void 0 ,
72
+ children : undefined ,
73
73
indent : parent . indent + 1
74
74
} ;
75
75
}
@@ -89,7 +89,7 @@ namespace ts.NavigationBar {
89
89
90
90
/** Call after calling `startNode` and adding children to it. */
91
91
function endNode ( ) : void {
92
- if ( parent . children !== void 0 ) {
92
+ if ( parent . children ) {
93
93
mergeChildren ( parent . children ) ;
94
94
sortChildren ( parent . children ) ;
95
95
}
@@ -104,7 +104,7 @@ namespace ts.NavigationBar {
104
104
105
105
/** Look for navigation bar items in node's subtree, adding them to the current `parent`. */
106
106
function addChildrenRecursively ( node : Node ) : void {
107
- if ( node === void 0 || isToken ( node ) ) {
107
+ if ( ! node || isToken ( node ) ) {
108
108
return ;
109
109
}
110
110
@@ -142,15 +142,15 @@ namespace ts.NavigationBar {
142
142
let importClause = < ImportClause > node ;
143
143
// Handle default import case e.g.:
144
144
// import d from "mod";
145
- if ( importClause . name !== void 0 ) {
145
+ if ( importClause . name ) {
146
146
addLeafNode ( importClause ) ;
147
147
}
148
148
149
149
// Handle named bindings in imports e.g.:
150
150
// import * as NS from "mod";
151
151
// import {a, b as B} from "mod";
152
152
const { namedBindings} = importClause ;
153
- if ( namedBindings !== void 0 ) {
153
+ if ( namedBindings ) {
154
154
if ( namedBindings . kind === SyntaxKind . NamespaceImport ) {
155
155
addLeafNode ( < NamespaceImport > namedBindings ) ;
156
156
}
@@ -169,7 +169,7 @@ namespace ts.NavigationBar {
169
169
if ( isBindingPattern ( name ) ) {
170
170
addChildrenRecursively ( name ) ;
171
171
}
172
- else if ( decl . initializer !== void 0 && isFunctionOrClassExpression ( decl . initializer ) ) {
172
+ else if ( decl . initializer && isFunctionOrClassExpression ( decl . initializer ) ) {
173
173
// For `const x = function() {}`, just use the function node, not the const.
174
174
addChildrenRecursively ( decl . initializer ) ;
175
175
}
@@ -218,7 +218,7 @@ namespace ts.NavigationBar {
218
218
break ;
219
219
220
220
default :
221
- if ( node . jsDocComments !== void 0 ) {
221
+ if ( node . jsDocComments ) {
222
222
for ( const jsDocComment of node . jsDocComments ) {
223
223
for ( const tag of jsDocComment . tags ) {
224
224
if ( tag . kind === SyntaxKind . JSDocTypedefTag ) {
@@ -238,13 +238,13 @@ namespace ts.NavigationBar {
238
238
filterMutate ( children , child => {
239
239
const decl = < Declaration > child . node ;
240
240
const name = decl . name && nodeText ( decl . name ) ;
241
- if ( name === void 0 ) {
241
+ if ( ! name ) {
242
242
// Anonymous items are never merged.
243
243
return true ;
244
244
}
245
245
246
246
const itemsWithSameName = getProperty ( nameToItems , name ) ;
247
- if ( itemsWithSameName === void 0 ) {
247
+ if ( ! itemsWithSameName ) {
248
248
nameToItems [ name ] = child ;
249
249
return true ;
250
250
}
@@ -297,12 +297,12 @@ namespace ts.NavigationBar {
297
297
function merge ( target : NavigationBarNode , source : NavigationBarNode ) : void {
298
298
target . additionalNodes = target . additionalNodes || [ ] ;
299
299
target . additionalNodes . push ( source . node ) ;
300
- if ( source . additionalNodes !== void 0 ) {
300
+ if ( source . additionalNodes ) {
301
301
target . additionalNodes . push ( ...source . additionalNodes ) ;
302
302
}
303
303
304
304
target . children = concatenate ( target . children , source . children ) ;
305
- if ( target . children !== void 0 ) {
305
+ if ( target . children ) {
306
306
mergeChildren ( target . children ) ;
307
307
sortChildren ( target . children ) ;
308
308
}
@@ -316,17 +316,17 @@ namespace ts.NavigationBar {
316
316
317
317
function compareChildren ( child1 : NavigationBarNode , child2 : NavigationBarNode ) : number {
318
318
const name1 = tryGetName ( child1 . node ) , name2 = tryGetName ( child2 . node ) ;
319
- if ( name1 !== void 0 && name2 !== void 0 ) {
319
+ if ( name1 && name2 ) {
320
320
const cmp = localeCompareFix ( name1 , name2 ) ;
321
321
return cmp !== 0 ? cmp : navigationBarNodeKind ( child1 ) - navigationBarNodeKind ( child2 ) ;
322
322
}
323
323
else {
324
- return name1 !== void 0 ? 1 : name2 !== void 0 ? - 1 : navigationBarNodeKind ( child1 ) - navigationBarNodeKind ( child2 ) ;
324
+ return name1 ? 1 : name2 ? - 1 : navigationBarNodeKind ( child1 ) - navigationBarNodeKind ( child2 ) ;
325
325
}
326
326
}
327
327
328
328
// More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times.
329
- const collator : { compare ( a : string , b : string ) : number } = typeof Intl === "undefined" ? void 0 : new Intl . Collator ( ) ;
329
+ const collator : { compare ( a : string , b : string ) : number } = typeof Intl === "undefined" ? undefined : new Intl . Collator ( ) ;
330
330
// Intl is missing in Safari, and node 0.10 treats "a" as greater than "B".
331
331
const localeCompareIsCorrect = collator && collator . compare ( "a" , "B" ) < 0 ;
332
332
const localeCompareFix : ( a : string , b : string ) => number = localeCompareIsCorrect ? collator . compare : function ( a , b ) {
@@ -358,7 +358,7 @@ namespace ts.NavigationBar {
358
358
}
359
359
360
360
const decl = < Declaration > node ;
361
- if ( decl . name !== void 0 ) {
361
+ if ( decl . name ) {
362
362
return getPropertyNameForPropertyNameNode ( decl . name ) ;
363
363
}
364
364
switch ( node . kind ) {
@@ -369,7 +369,7 @@ namespace ts.NavigationBar {
369
369
case SyntaxKind . JSDocTypedefTag :
370
370
return getJSDocTypedefTagName ( < JSDocTypedefTag > node ) ;
371
371
default :
372
- return void 0 ;
372
+ return undefined ;
373
373
}
374
374
}
375
375
@@ -379,7 +379,7 @@ namespace ts.NavigationBar {
379
379
}
380
380
381
381
const name = ( < Declaration > node ) . name ;
382
- if ( name !== void 0 ) {
382
+ if ( name ) {
383
383
const text = nodeText ( name ) ;
384
384
if ( text . length > 0 ) {
385
385
return text ;
@@ -418,7 +418,7 @@ namespace ts.NavigationBar {
418
418
}
419
419
420
420
function getJSDocTypedefTagName ( node : JSDocTypedefTag ) : string {
421
- if ( node . name !== void 0 ) {
421
+ if ( node . name ) {
422
422
return node . name . text ;
423
423
}
424
424
else {
@@ -441,7 +441,7 @@ namespace ts.NavigationBar {
441
441
function recur ( item : NavigationBarNode ) {
442
442
if ( isTopLevel ( item ) ) {
443
443
topLevel . push ( item ) ;
444
- if ( item . children !== void 0 ) {
444
+ if ( item . children ) {
445
445
for ( const child of item . children ) {
446
446
recur ( child ) ;
447
447
}
@@ -478,7 +478,7 @@ namespace ts.NavigationBar {
478
478
return false ;
479
479
}
480
480
function isTopLevelFunctionDeclaration ( item : NavigationBarNode ) : boolean {
481
- if ( ( < FunctionDeclaration > item . node ) . body === void 0 ) {
481
+ if ( ! ( < FunctionDeclaration > item . node ) . body ) {
482
482
return false ;
483
483
}
484
484
@@ -531,7 +531,7 @@ namespace ts.NavigationBar {
531
531
532
532
function getSpans ( n : NavigationBarNode ) : TextSpan [ ] {
533
533
const spans = [ getNodeSpan ( n . node ) ] ;
534
- if ( n . additionalNodes !== void 0 ) {
534
+ if ( n . additionalNodes ) {
535
535
for ( const node of n . additionalNodes ) {
536
536
spans . push ( getNodeSpan ( node ) ) ;
537
537
}
@@ -562,7 +562,7 @@ namespace ts.NavigationBar {
562
562
while ( variableDeclarationNode && variableDeclarationNode . kind !== SyntaxKind . VariableDeclaration ) {
563
563
variableDeclarationNode = variableDeclarationNode . parent ;
564
564
}
565
- Debug . assert ( variableDeclarationNode !== void 0 ) ;
565
+ Debug . assert ( ! ! variableDeclarationNode ) ;
566
566
}
567
567
else {
568
568
Debug . assert ( ! isBindingPattern ( ( < VariableDeclaration > node ) . name ) ) ;
@@ -620,17 +620,17 @@ namespace ts.NavigationBar {
620
620
}
621
621
622
622
function isComputedProperty ( member : EnumMember ) : boolean {
623
- return member . name === void 0 || member . name . kind === SyntaxKind . ComputedPropertyName ;
623
+ return ! member . name || member . name . kind === SyntaxKind . ComputedPropertyName ;
624
624
}
625
625
626
626
function getNodeSpan ( node : Node ) : TextSpan {
627
627
return node . kind === SyntaxKind . SourceFile
628
628
? createTextSpanFromBounds ( node . getFullStart ( ) , node . getEnd ( ) )
629
- : createTextSpanFromBounds ( node . getStart ( sourceFile ) , node . getEnd ( ) ) ;
629
+ : createTextSpanFromBounds ( node . getStart ( curSourceFile ) , node . getEnd ( ) ) ;
630
630
}
631
631
632
632
function getFunctionOrClassName ( node : FunctionExpression | FunctionDeclaration | ArrowFunction | ClassLikeDeclaration ) : string {
633
- if ( node . name !== void 0 && getFullWidth ( node . name ) > 0 ) {
633
+ if ( node . name && getFullWidth ( node . name ) > 0 ) {
634
634
return declarationNameToString ( node . name ) ;
635
635
}
636
636
// See if it is a var initializer. If so, use the var name.
0 commit comments