Skip to content

Ways to get named type from Static? Issues? #911

Answered by sinclairzx81
ghost asked this question in Q&A
Discussion options

You must be logged in to vote

@waynebloss Hi,

Ah, that's a interesting approach. There isn't really a standard / non-standard way to produce named type in TypeBox, but the technique you suggest seems very reasonable to me, I actually quite like it.

In terms of issues, I wouldn't anticipate any, but just to be mindful that extends Static<T> is only workable for types that produce structural object types. In terms of other approaches, there's none that I know of (as all conditional mapped types are computed type aliases), but if there is a technique, i would be interested in including that in TypeBox, the following would be ideal.

const T = NamedStatic<typeof T> // this would be ideal

Maybe one day :)

Hope this helps
S

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sinclairzx81
Comment options

Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant