Skip to content

Can't add doc comment for a type definition using and #6844

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
DZakh opened this issue Jul 1, 2024 · 2 comments · Fixed by #7001
Closed

Can't add doc comment for a type definition using and #6844

DZakh opened this issue Jul 1, 2024 · 2 comments · Fixed by #7001
Assignees
Milestone

Comments

@DZakh
Copy link
Member

DZakh commented Jul 1, 2024

For the code:

type pathItem = {}
/**
Describes a single API operation on a path.
 */
and operation =  {}

I get

Did you forget to attach `res.doc` to an item?
  Standalone attributes start with `@@` like: `@@res.doc`

https://rescript-lang.org/try?version=v11.1.2&code=FAFwngDgpgBBCGIAWBJEUC2MC8MDeAvsAPQBUpwAIlAM4DGATgJYBGtM8MNTAdgOYAbWAEEACihgB7aA0RNJPKYs4JkAOmAxSxYPB4ATKTLkKcMfASA

Putting it in another place returns different, but still weird error:

type pathItem = {}
and /**
Describes a single API operation on a path.
 */ operation =  {}
I'm expecting a lowercase name like `user or `age`

https://rescript-lang.org/try?version=v11.1.2&code=FAFwngDgpgBBCGIAWBJEUC2MC8MDeAvsMPAHYAmMA9AFQ3AAiUAzgMYBOAlgEYszwxmnUgHMANrACCABRQwA9tHaJO80gvUCEyAHTAYNKgqUq1OGPgJA

And a third error for another case:

type pathItem = {}
and operation = /**
Describes a single API operation on a path.
*/ {a: string}
 An inline record type declaration is only allowed in a variant constructor's declaration

https://rescript-lang.org/try?version=v11.1.2&code=C4TwDgpgBGCGwAsCSwIFsoF4oG8C+AULAHYAmUA9pAE7wCWFxWUA9AFRsEAiEAzgMbU6AIz5RYUXnWIBzADbQAggAUklGvUaUmEuIgB0BKGxa5YALknAhswkA

@zth
Copy link
Collaborator

zth commented Jul 1, 2024

Seems the problem is when the doc comment is the only thing (as in, not preceded by an annotation): https://rescript-lang.org/try?version=v11.1.2&code=C4TwDgpgBGCGwAsCSwIFsoF4oG8C+AUAAIBOEAzgHQAmA9gMYAUARACIX0kCWARhVLCjkuAOwDmAG2gBBAApIotSCXhdaIxRsFxElZgEoCAegBUJqO3Kde-QcPFSochUogrgajeoEx4CSlAmRgSwItSKyqre2DiwAFxCwNzihEA

To work around it for now you can use @res.doc and not format.

@cristianoc
Copy link
Collaborator

Then it should be a parser issue.

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

Successfully merging a pull request may close this issue.

4 participants