Static<typeof Model> vs typeof Model.static #603
-
Is there a major difference or any drawbacks to inferring types like in example 1? //example 1
type T = typeof Model.static; //example 2
import { Static } from "@sinclair/typebox";
type T = Static<typeof Model> I quite like doing typeof Model.static, and wasn't sure if there is a downside to inferring types like that. It also saves an extra import , and is useful for quickly inning the type definition. In zod I would do something like type T = typeof Schema._type as opposed to type T = z.infer<typeof Schema> |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@pauldvu Hi, You should be able to use Hope that helps! |
Beta Was this translation helpful? Give feedback.
@pauldvu Hi,
You should be able to use
typeof T.static
orStatic<typeof T>
interchangeable. You're free to use either form, but be mindful that the.static
property is a phantom property, and the Static usage does provide an abstraction over that detail.Hope that helps!
S