A
arktype3w ago
Micha

Is there a way to preserve jsdoc in arktype?

I have this piece of code:
/**
* Defines a {@link https://docs.fauna.com/fauna/current/learn/security/roles/#user-defined-role | user-defined role}. A role determines an authentication secret’s privileges, which control data access.
*
* Fauna stores user-defined roles as documents in the `Role` system collection. See {@link https://docs.fauna.com/fauna/current/reference/fql-api/auth/role/ | Role}.
*/
const role = type({
/**
* Assigns the role to tokens based on the {@link https://docs.fauna.com/fauna/current/learn/security/tokens/ | token’s} identity document. See for more information on {@link https://fauna.com/docs/reference/javascript#membership-roles | Membership definition}.
*/
"membership?": "string",
/**
* Allows one or more actions on a resource. See {@link https://docs.fauna.com/fauna/current/reference/fsl/role/#privileges-definition | Privileges definition}.
*/
"privileges?": "string",
});

export type Role = typeof role;
/**
* Defines a {@link https://docs.fauna.com/fauna/current/learn/security/roles/#user-defined-role | user-defined role}. A role determines an authentication secret’s privileges, which control data access.
*
* Fauna stores user-defined roles as documents in the `Role` system collection. See {@link https://docs.fauna.com/fauna/current/reference/fql-api/auth/role/ | Role}.
*/
const role = type({
/**
* Assigns the role to tokens based on the {@link https://docs.fauna.com/fauna/current/learn/security/tokens/ | token’s} identity document. See for more information on {@link https://fauna.com/docs/reference/javascript#membership-roles | Membership definition}.
*/
"membership?": "string",
/**
* Allows one or more actions on a resource. See {@link https://docs.fauna.com/fauna/current/reference/fsl/role/#privileges-definition | Privileges definition}.
*/
"privileges?": "string",
});

export type Role = typeof role;
At the moment the TS type Role don't have JsDoc as part of Intellisense. Also, role has only the overall jsdoc, but not for the key membership & privileges
1 Reply
ssalbdivad
ssalbdivad3w ago
This isn't really possible with ArkType's standard API that includes key parsing due to how TS handles it, but is potentially doable if you want to use type.string.optional() or similar instead of "privileges?". Feel free to create an issue and we can investigate at some point.

Did you find this page helpful?