Skip to content

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

Closed

Description

@DZakh

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

Activity

  1. zth commented on Jul 1, 2024

    @zth
    Member

    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.

  2. cristianoc commented on Jul 1, 2024

    @cristianoc
    Collaborator

    Then it should be a parser issue.

  3. added this to the v12 milestone on Jul 26, 2024
  4. self-assigned this
    on Sep 1, 2024
  5. added theissue type on Jul 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions