documentationjs / documentation

:book: documentation for modern JavaScript
http://documentation.js.org/
Other
5.79k stars 482 forks source link

TypeError: Cannot read property 'name' of undefined (graphql codegen with flow) #1350

Open josefjadrny opened 3 years ago

josefjadrny commented 3 years ago

Hi, i am experiencing the following error with graphql codegenerator tool with flow. Generated code looks fine, but documentation returns an Error.

test.flow.js

// @flow

/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {|
  ID: string,
  String: string,
  Boolean: boolean,
  Int: number,
  Float: number,
|};

/** Some description */
export type EpisodeAggregation = {|
  ...Aggregation,
  ...{|
    __typename?: 'EpisodeAggregation',
    /** The ID of an object */
  id: $ElementType<Scalars, 'ID'>,
  |}
|};

export type Aggregation = {|
  __typename?: 'Aggregation',
  /** The ID of an object */
  id: $ElementType<Scalars, 'ID'>,
|};

$ documentation lint test.flow.js

TypeError: Cannot read property 'name' of undefined
    at isObjectSpreadAndExactUtilTypeProperty (/usr/local/lib/node_modules/documentation/src/infer/properties.js:15:26)
    at /usr/local/lib/node_modules/documentation/src/infer/properties.js:87:13
    at Array.forEach (<anonymous>)
    at inferProperties (/usr/local/lib/node_modules/documentation/src/infer/properties.js:79:18)
    at Array.inferProperties (/usr/local/lib/node_modules/documentation/src/infer/properties.js:104:7)
    at /usr/local/lib/node_modules/documentation/src/index.js:40:25
    at Array.map (<anonymous>)
    at /usr/local/lib/node_modules/documentation/src/index.js:149:48
    at arrayMap (/usr/local/lib/node_modules/documentation/node_modules/lodash/lodash.js:639:23)
    at map (/usr/local/lib/node_modules/documentation/node_modules/lodash/lodash.js:9580:14)

My code is autogenerated by https://graphql-code-generator.com from this query

"Some description"
type EpisodeAggregation implements Aggregation {
    "The ID of an object"
    id: ID!
}

type Aggregation {
    "The ID of an object"
    id: ID!
}
josefjadrny commented 3 years ago

Remove this comment /** Some descriptition */ and it magically works. In my case, unfortunately, it is autogenerated.