Feature request: make all wrapper factory functions public
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 238
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
**Is your feature request related to a problem? Please describe.**
As mentioned in #1418, #1421 there are cases where we need essential information deep inside the compiler types that we can't navigate to with the ts-morph API, like `type.origin`.
In many cases `type.compilerType` would be sufficient to work with. But this became a roadblock for us because we started out with a recursive function that takes a `ts-morph` `Type` wrapper and generates zod schema declarations, and now realized we'd like to call it on `type.compilerType.origin` in some cases where TS is flattening unions of type aliases and enums. So we either have to refactor our function to use raw TS compiler API or get a ts-morph wrapper for `type.compilerType.origin`.
In general, not being able to go from compiler object to wrapper seems prone to becoming a roadblock like this, so I think all of the wrapper factory functions should be exposed.
If only `Type._context` were not `@internal` then we could do `type._context.compilerFactory.getType(type.compilerType.origin)` and keep going. I feel on the fence about whether to basically do that and suppress errors since that API isn't in the .d.ts, or just use plain TS compiler API everywhere.
But it would be a bummer not to be able to use `ts-morph` because it's been really nice and convenient up to this point 🙂
**Describe the solution you'd like**
`CompilerFactory` being officially public API, or at least some public way to get a wrapper for every compiler object type.
**Describe alternatives you've considered**
Contributor guide
Research direction
Read CONTRIBUTING.md, then inspect CompilerFactory, Type._context, and compilerFactory.getType around the wrapper creation path. Review the related context in #1418 and #1421 and identify the full set of wrapper factory functions. Done means the supported public API boundary is defined and covers the requested compiler-object-to-wrapper use case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100