Closed s-egea closed 1 year ago
@s-egea Hi! this is good spotting!
I really liked your solution and have applied it on update on 0.28.12
. Tested both enum
and your object literal definition, and it looks like it works great! Nice work :)
Will close off this issue for now, but if you spot any problems, feel free to let me know on this thread. All the best! S
Thanks for the quick reply and update ! 👍
Static type resulting from the nesting of a
Type.Enum
in aType.TemplateLiteral
transforms original const literal type into a more general string type. Here is a small reproduction:As far as I can understand this behavior comes from this part of the code (src/typebox.ts)
where type
U
get inferred as aTLiteral<string | number>[]
whenT
is aTEnum
.The following change seems to produce the desired behavior (src/typebox.ts):