dsherret / dsherret/ts-morph

.getChildSyntaxList() unexpectedly returns undefined for UnionTypeNode

Open
#1,472 1 comment 0 reactions 0 assignees View on GitHub
bug good first issue
Dominant language
TypeScript
Stars
6.2k
Forks
238
Avg merge
2m
Merged PRs (30d)
1

Description

**Describe the bug**

Version: 20.0.0

The `.getChildSyntaxList()` method on UnionTypeNode does not work - it returns undefined even though UnionTypeNode has a direct SyntaxList child node:

![Screenshot 2023-11-15 at 10 40 07](https://github.com/dsherret/ts-morph/assets/40512816/8720f72f-cf6b-4c15-91a1-48badba5d938)

**To Reproduce**

```ts
import { Project } from "ts-morph";

const project = new Project();
const sourceFile = project.createSourceFile("test.ts", `

const a: string | undefined;
`);

const unionTypeNode = sourceFile.getVariableDeclaration('a').getTypeNode();
unionTypeNode.getChildSyntaxList(); // undefined
```

**Expected behavior**

Child syntax list should be returned

Contributor guide

Open the contributing guide

Research direction

Read CONTRIBUTING.md, then start at UnionTypeNode.getChildSyntaxList() and reproduce the behavior with the TypeScript snippet in the issue. Done means the call returns the direct child SyntaxList for the union type instead of undefined, with the reproduction confirming the expected result.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
devtools
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.