Replies: 1 comment
-
Unfortunately we don't yet have support for mapped types, so there is no way to compute this type transformation in TypeSpec itself. You can write a decorator that affects this transformation, but it is fairly annoying. You can look at how e.g. the withVisibility decorator works. But combined with a template, you could use this to build the template you want. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Question
Is it possible to generate keys to one definition from the keys of another?
Example
Given the following definition:
The goal is to make an object for
@body formErrors
on a 400 status code. This means validation of the data submitted has failed. We would like to have is something that says, "For any properties in the User model, they may be present here with a value that is a string or array of strings." Then we may also add extra manual properties like `reason: "Validation Failed" to supplement the object.I can't find any clear way of doing this from the docs available. Is this kind of thing possible with the currently available definitions in TypeSpec? I know I could do it using Typescript with something like the following:
Beta Was this translation helpful? Give feedback.
All reactions