dsherret / dsherret/ts-morph

[Question] How to extract argument from generic type?

Open
#1,616 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
6.2k
Forks
238
Avg merge
2m
Merged PRs (30d)
1

Description

It's either a brain fart or an actual issue.

```ts
export type MutableStep1Dto = MutableDto;
```

I want to extract the second argument of `MutableDto` to count the union members. I tried walking the nodes but it just doesn't yield the expected types as seen in the AST viewer, see https://ts-ast-viewer.com/#code/FAUwHgDg9gTgLgAjgTwiBBZArnAhgIwBsQBlOECANgBE4oEBeTHA42qAHjIproBoEAIiwBnEDAAqqEIIQAfIRBhQ08ZFLQjBAPgDcQA.

Contributor guide

Open the contributing guide

Research direction

Begin with the generic type example in the issue and compare ts-morph's node-walking behavior with the linked AST viewer. Confirm how to reach MutableDto's second argument and count its union members, then document the result with a focused reproduction or response.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.