You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! Is there a particular reason Type.Extends() doesn't currently work with Unsafe, Recursive, or Module.Import types?
Recursive and Module.Import types specifically seem like they should be resolvable. I get that the "excessively deep and possibly infinite" case is a possibility with recursive types like this, but if Typescript can resolve these types, seems like Typebox should be able to as well? Here are the errors I'm currently getting:
Type.Extends(Type.Module({a: Type.String(),b: Type.Ref('a'),}).Import('b'),Type.String(),Type.Literal(true),Type.Literal(false));// ExtendsResolverError: Unknown left type operand 'Import'
And I can conceptually understand why Unsafe types can't be tested, but maybe there's a way to specify a way how they can be tested in Extends? At the very least, couldn't Extends return true if left and right are the identical Unsafe type? Or perhaps by comparing their Kind?
constunsafeType=Type.Unsafe();Type.Extends(unsafeType,unsafeType,Type.Literal(true),Type.Literal(false));// ExtendsResolverError: Unknown left type operand 'Unsafe'
Love all that Typebox is doing! Been playing around with it to do some cool runtime type math, but ran into these roadblocks. So I'm wondering if there's a reason for these cases not being implemented?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi! Is there a particular reason Type.Extends() doesn't currently work with Unsafe, Recursive, or Module.Import types?
Recursive and Module.Import types specifically seem like they should be resolvable. I get that the "excessively deep and possibly infinite" case is a possibility with recursive types like this, but if Typescript can resolve these types, seems like Typebox should be able to as well? Here are the errors I'm currently getting:
And I can conceptually understand why Unsafe types can't be tested, but maybe there's a way to specify a way how they can be tested in Extends? At the very least, couldn't Extends return true if left and right are the identical Unsafe type? Or perhaps by comparing their Kind?
Love all that Typebox is doing! Been playing around with it to do some cool runtime type math, but ran into these roadblocks. So I'm wondering if there's a reason for these cases not being implemented?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions