(partial: Partial<TSNodeLike> & { type: string }, children: TSNodeLike[] = [])
| 23 | } |
| 24 | |
| 25 | function node(partial: Partial<TSNodeLike> & { type: string }, children: TSNodeLike[] = []): TSNodeLike { |
| 26 | return { |
| 27 | childCount: children.length, |
| 28 | child: (i: number) => children[i] ?? null, |
| 29 | startPosition: { row: 0, column: 0 }, |
| 30 | hasError: children.some(c => boolErr(c)) || partial.type === 'ERROR' || !!partial.isMissing, |
| 31 | ...partial, |
| 32 | } as TSNodeLike; |
| 33 | } |
| 34 | function boolErr(n: TSNodeLike): boolean { |
| 35 | const h = (n as any).hasError; |
| 36 | return typeof h === 'function' ? h() : !!h; |
no test coverage detected