sinclairzx81 / typebox

Json Schema Type Builder with Static Type Resolution for TypeScript
Other
4.56k stars 148 forks source link

Enum type inferred as never when using Type.Mapped() #897

Closed tchyra closed 4 weeks ago

tchyra commented 4 weeks ago

Reproduction:

enum E { O1, O2 }

const T = Type.Object({ a: Type.Enum(E) });                     // TObject<{ a: TEnum<typeof E> }>
type T = Static<typeof T>;                                      // { a: E }

const U = Type.Mapped(Type.KeyOf(T), K => Type.Index(T, K));    // TObject<{ a: TUnion<[]> }>
type U = Static<typeof U>;                                      // { a: never; }

Thank you for your work on Typebox, it's proven quite useful :)

sinclairzx81 commented 4 weeks ago

@tchyra Hi, thanks for reporting!

Have just pushed a update to fix this on 0.32.32. You should be able to test the update at the following URL (just be sure to clear out your cache)

TypeScript Link Here

Will close up this issue for now, but if you run into any issues, feel free to post on this thread. All the best! S

tchyra commented 4 weeks ago

Updated in my project and it seems to work perfectly, thank you very much for fixing this so quickly!