As a follow-up to #2831, please consider adding .getTrueType() and .getFalseType() to ConditionalType interface:
|
/** Conditional types — T extends U ? X : Y (TypeFlags.Conditional) */ |
|
export interface ConditionalType<Async extends boolean> extends Type<Async> { |
|
/** Get the check type T in `T extends U ? X : Y` */ |
|
getCheckType(): MaybeAsync<Async, Type<Async>>; |
|
/** Get the extends type U in `T extends U ? X : Y` */ |
|
getExtendsType(): MaybeAsync<Async, Type<Async>>; |
|
} |
The above interface does not provide getters for X and Y types. I can’t be sure if I am missing something, of course.
The ConditionalType interface in Strada includes resolvedTrueType?: Type and resolvedFalseType?: Type. The properties are created lazily and therefore are not very useful.
As a workaround, it is to utilize one or another .getType*() method by passing ConditionalType#root.node.trueType and ConditionalType#root.node.falseType (here, or here).
That does not work well with more complex types, because the resulting types are not instantiated.
I was playing with the internals of Strada. It seemed like the best solution would be to be able to use getTrueTypeFromConditionalType() and getFalseTypeFromConditionalType(). These method return instantiated types, but it might be that there is something more complex than I could grasp.
I only wanted to draw your attention to the missing .getTrueType() and .getFalseType() getters. And a possible solution.
As a follow-up to #2831, please consider adding
.getTrueType()and.getFalseType()toConditionalTypeinterface:typescript-go/_packages/api/src/base/api.ts
Lines 400 to 406 in 023a4c9
The above interface does not provide getters for
XandYtypes. I can’t be sure if I am missing something, of course.The
ConditionalTypeinterface in Strada includesresolvedTrueType?: TypeandresolvedFalseType?: Type. The properties are created lazily and therefore are not very useful.As a workaround, it is to utilize one or another
.getType*()method by passingConditionalType#root.node.trueTypeandConditionalType#root.node.falseType(here, or here).That does not work well with more complex types, because the resulting types are not instantiated.
I was playing with the internals of Strada. It seemed like the best solution would be to be able to use
getTrueTypeFromConditionalType()andgetFalseTypeFromConditionalType(). These method return instantiated types, but it might be that there is something more complex than I could grasp.I only wanted to draw your attention to the missing
.getTrueType()and.getFalseType()getters. And a possible solution.