Feature request: "Type alias to stub class" API
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 238
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
TypeScript, for all its power, does not give us a simple way to take a complex type (mapped type with additional arguments, for example) and generate a stub class. Thanks to this project, I've been able to implement a ["type to stub class"](https://github.com/ajvincent/cross-stitch/tree/main/_01_ts-morph_utilities) API.
I'm just nuts enough to think this would be very useful to have in the toolbox.
**Describe the solution you'd like**
I've tried to write this to be general-purpose. At the very least, I'd appreciate a review of the code, even if it's turned down for inclusion in this project. I'd like to see if ts-morph would be willing to adopt it as part of its standard API.
I am willing to contribute this code. That said, I did have a recent incident where I was over-enthusiastic about a particular feature I wanted to add to another project, with other parties also interested. That enthusiasm blew up in my face on an inter-personal level with the other developers. I'd very much like to not repeat that mistake. I also recognize that other people have limited time to offer.
**Describe alternatives you've considered**
I have not seen this particular capability in the open-source community. [Just getting the list of properties a type specifies is difficult.](https://stackoverflow.com/questions/68531850/typescript-compiler-api-get-type-structure)
I first tried to do this using TypeScript-ESLint's parser. As I approached the more complex types, I realized I might end up re-implementing a lot of TypeScript's type checking. This led me to the [Discord channel for TypeScript's internal API's](https://discord.com/channels/508357248330760243/640177429775777792), which led me to this project and ultimately the solution I came up with.
Contributor guide
Research direction
Read CONTRIBUTING.md first, then review the proposed implementation in the linked cross-stitch _01_ts-morph_utilities directory. Compare its general-purpose type-to-stub-class API with ts-morph's existing capabilities; done requires a maintainer decision on whether the API belongs in the standard project.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100