File tree 2 files changed +4
-12
lines changed 2 files changed +4
-12
lines changed Original file line number Diff line number Diff line change @@ -8,20 +8,12 @@ export function getNodeChildren(node: Node): Node[] | undefined {
8
8
}
9
9
10
10
/** @internal */
11
- export function setNodeChildren ( node : Node , children : Node [ ] ) {
11
+ export function setNodeChildren ( node : Node , children : Node [ ] ) : Node [ ] {
12
12
nodeChildren . set ( node , children ) ;
13
+ return children ;
13
14
}
14
15
15
16
/** @internal */
16
17
export function unsetNodeChildren ( node : Node ) {
17
18
nodeChildren . delete ( node ) ;
18
19
}
19
-
20
- /** @internal */
21
- export function getOrSetNodeChildren ( node : Node , fn : ( ) => Node [ ] ) : Node [ ] {
22
- let children = getNodeChildren ( node ) ;
23
- if ( children === undefined ) {
24
- setNodeChildren ( node , children = fn ( ) ) ;
25
- }
26
- return children ;
27
- }
Original file line number Diff line number Diff line change @@ -106,10 +106,10 @@ import {
106
106
getNameFromPropertyName ,
107
107
getNewLineCharacter ,
108
108
getNewLineOrDefaultFromHost ,
109
+ getNodeChildren ,
109
110
getNonAssignedNameOfDeclaration ,
110
111
getNormalizedAbsolutePath ,
111
112
getObjectFlags ,
112
- getOrSetNodeChildren ,
113
113
getQuotePreference ,
114
114
getScriptKind ,
115
115
getSetExternalModuleIndicator ,
@@ -438,7 +438,7 @@ class NodeObject<TKind extends SyntaxKind> implements Node {
438
438
439
439
public getChildren ( sourceFile ?: SourceFileLike ) : Node [ ] {
440
440
this . assertHasRealPosition ( "Node without a real position cannot be scanned and thus has no token nodes - use forEachChild and collect the result if that's fine" ) ;
441
- return getOrSetNodeChildren ( this , ( ) => createChildren ( this , sourceFile ) ) ;
441
+ return getNodeChildren ( this ) ?? setNodeChildren ( this , createChildren ( this , sourceFile ) ) ;
442
442
}
443
443
444
444
public getFirstToken ( sourceFile ?: SourceFileLike ) : Node | undefined {
You can’t perform that action at this time.
0 commit comments