Replies: 1 comment 1 reply
-
|
@rolanday Hi! Sorry for the delay here (and thank you so much for the nice words!). It has been a long technical year this one, and it's nice to hear feedback like this from time to time :) I really appreciate it.
Um, possibly. I'm not sure at this stage. A lot of the work in TB V1 was done to try and incorporate the codegen project into TB directly under the new Type.Script API. This has built in JSON-Schema generation (but would need remapping back out to the source code representations for each library generated by codegen) import Type from 'typebox'
// Hover these for inference (should match the scripted type)
export type Foo = Type.Static<typeof Foo>
export type Bar = Type.Static<typeof Bar>
// Copy and paste TS types into Type.Script(...) and get back type-safe JSON Schema
export const { Foo, Bar } = Type.Script(`
type Foo = {
x: number
y: number
z: number
}
type Bar = {
readonly [K in keyof Foo as Map<K>]: Advanced<K> | Foo[K]
}
type Advanced<Key, Variants = 'X' | 'Y' | 'Z'> = (
\`\${Uppercase<Key>}\${Variants}-impossible\`
)
type Map<Key> = Uppercase<
Key extends 'x' ? 'a' :
Key extends 'y' ? 'b' :
Key extends 'z' ? 'c' :
never
>
`)
// Output types are fully reflectable JSON Schema
Foo.type // 'object'
Foo.properties // { x: ..., y: ..., z: ... }
Foo.required // ['x', 'y', 'z']So, I'm not sure whether to keep this project going, or replace the TSC compiler with TB, or take some other path. So still somewhat mulling the options (and the TS emulation in TB still have a few things to implement, and it's not entirely ready to replace codegen 1-1). I am open to keeping it going if it's useful to developers, but mostly just considering the options for now. If it is just a case of ReadonlyOptional, I can probably support that (or provide a new TBV1 generation target), maybe this is the easier option. Would this help? Let me know! :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, @sinclairzx81 :) Congrats on typebox 1.0. Any plans to bring codegen forward as well? Codegen is still working for me, but i needed to do some minor post-processing because or ReadonlyOptional. Please lmk -- if no plans, I may start to slowly wean myself off of it. Regardless of plan, super appreciate all your effort to bring best-in-class type validation to us. It's the only TS validator I use and recommend, for personal and work. Ty!!
Beta Was this translation helpful? Give feedback.
All reactions