rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

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

Open DZakh opened this issue 1 year ago • 2 comments

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

DZakh avatar Jul 01 '24 07:07 DZakh

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.

zth avatar Jul 01 '24 09:07 zth

Then it should be a parser issue.

cristianoc avatar Jul 01 '24 16:07 cristianoc