Skip to content

JSDocs for parameters are incorrect #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
needim opened this issue Sep 7, 2022 · 1 comment · Fixed by #92
Closed

JSDocs for parameters are incorrect #91

needim opened this issue Sep 7, 2022 · 1 comment · Fixed by #92

Comments

@needim
Copy link
Collaborator

needim commented Sep 7, 2022

Hi,

I have noticed that JSDoc comments for parameters are not actual JSDoc comments. (Line[104, 108, 114])

For example:

/**
* Set secrets for GitHub Actions.
*/
export type ActionsSecret = {
/*
* @format date-time
*/
created_at: string;
/*
* The name of the secret.
*
* @example SECRET_TOKEN
*/
name: string;
/*
* @format date-time
*/
updated_at: string;
};

they should start with /** not /*

I noticed this while I was testing https://github.com/fabien0102/ts-to-zod

Even in the tests, JSDoc comments start with /* [Line 145]

"/**
* Generated by @openapi-codegen
*
* @version 1.0.0
*/
/**
* A new pet.
*/
export type Pet = NewPet & {
/*
* @format int64
*/
id: number;
};

For a reference from https://github.com/fabien0102/zod-schema-from-stripe

https://github.com/fabien0102/zod-schema-from-stripe/blob/b3a3156f7ca54d4dc411dfa826dfc2d8cd4e5a0c/src/stripe/stripeSchemas.ts#L150-L156

Because of this fabien0102/ts-to-zod can't generate correct zod schemas. It is ignoring maxLength, etc.

@needim
Copy link
Collaborator Author

needim commented Sep 7, 2022

Looks like this is related to this TypeScript issue.

microsoft/TypeScript#17146

I can come up with a quick fix until this issue is solved. If this approach is acceptable.

  ts.addSyntheticLeadingComment(
    node,
    ts.SyntaxKind.MultiLineCommentTrivia,
    "*" + jsDocString, // https://github.com/microsoft/TypeScript/issues/17146
    true
  );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant