Replies: 1 comment 2 replies
-
@pdfowler Hi, Unfortunately (and to the best of my knowledge) there isn't a way to map JSDoc comments onto types through the TS type system. At this time it is only possible to retain existing user defined JSDoc comments (as per example 4) where the compiler associates the comment with the property, and where mapping that property carefully will also bring the comment over. This limitation is mostly due to current capabilities of TypeScript's type mapping syntax, where there isn't a way to programmatically map comments. However, something like the following would be ideal... // Where the doc comment string can be interpolated via ${...} inline using template literals types.
type T = number extends string ? {
/**
* @description ${'I'm a number'}
*/
x: number
} : {
/**
* @description ${'I'm a string'}
*/
x: string
} ...where the Because of the above limitation, users will need to duplicate both doc comment and Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
We're updating our feathers api code to use TypeBox as the source of truth for our models and types, but struggling with the DX while viewing (within VSCode) the associated metadata (eg:
description
) for each field. I'm guessing this is more of a VSCode issue, but wanted to raise the question here first.Code
VSCode Tooltip
Useful?
So, is adding the block comment to my TypeBox schema the only way to get field information to appear in VSCode? My ideal state would be that the description would be stored in the schema's
description
field (structured) and not as a comment for each field. If so, I'm afraid we start getting into a worst-case-scenario of this info being duplicated in the block comment and in the schema'sdescription
field.TL;DR:
Static<T>
type to make thedescription
field (andtitle
) more available to VSCode?Beta Was this translation helpful? Give feedback.
All reactions