gatsby: [gatsby-transformer-react-docgen] throws conflicting field types warning
Description
gatsby-transformer-react-docgen
throws “There are conflicting field types in your data” warning depending on the PropTypes.
Here are two components that conflict:
Button.propTypes = {
type: PropTypes.oneOf(['button', 'submit']),
}
DatePicker.propTypes = {
lastMonth: PropTypes.instanceOf(Date),
}
Steps to reproduce
I’ve created a repo to demonstrate this bug:
git clone git@github.com:danoc/gatsby-react-docgen-repro.git && cd gatsby-react-docgen-repro && yarn && yarn develop
- See warning in console.
Expected result
Shouldn’t start development environment without throwing warning.
Actual result
Warning appears:
warning There are conflicting field types in your data. GraphQL schema will omit those fields.
ComponentProp.type.value:
- type: array<object>
value: [ { value: '\'button\'', computed: false }, ... ]
source: File "conflicting-components/Button.jsx"
- type: string
value: 'Date'
source: File "conflicting-components/DatePicker.jsx"
ComponentProp.parentType.value:
- type: array<object>
value: [ { value: '\'button\'', computed: false }, ... ]
source: File "conflicting-components/Button.jsx"
- type: string
value: 'Date'
source: File "conflicting-components/DatePicker.jsx"
Environment
I’m running v2, but this happens in both v1 and v2.
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
Shell: 5.5.1 - /usr/local/bin/zsh
Binaries:
Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node
Yarn: 1.7.0 - /usr/local/bin/yarn
npm: 5.6.0 - ~/.nvm/versions/node/v8.11.3/bin/npm
Browsers:
Chrome: 68.0.3440.84
Firefox: 61.0.1
Safari: 11.1.2
npmPackages:
gatsby: next => 2.0.0-beta.69
gatsby-source-filesystem: next => 2.0.1-beta.10
gatsby-transformer-react-docgen: next => 2.1.1-beta.4
File contents (if changed)
gatsby-config.js
: N/A
package.json
: N/A
gatsby-node.js
: N/A
gatsby-browser.js
: N/A
gatsby-ssr.js
: N/A
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 19 (10 by maintainers)
They types aren’t conflicting, there is a false positive because the fields in question are JSON scalars but the Gatsby inference logic thinks they are objects and lists. I actually “fixed” this problem previously, where it wasn’t compiling but it seems like it’s still starting to print a warning even tho there aren’t any conflicts to print
Same error noticed when I ran reproduction.