Object type spread failing on imported type from other module or libdef (e.g. flow-typed)
See original GitHub issuebabel-7
branch - I’m looking into this. found
is in a local libdef.
import type {RoutingState} from 'found'
type Props = {
...$Exact<RoutingState>,
classes: Object,
children?: Element<*>,
currentUser?: CurrentUser,
t: Function,
width: string,
}
TypeError: src/App/AppFrame.js: Cannot read property 'key' of undefined
at /Users/kross/projects/ui/node_modules/@alienfast/babel-plugin-flow-react-proptypes/lib/makePropTypesAst.js:154:19
at Array.map (native)
at makeObjectAstForShape (/Users/kross/projects/ui/node_modules/@alienfast/babel-plugin-flow-react-proptypes/lib/makePropTypesAst.js:153:48)
at makePropTypesAstForPropTypesAssignment (/Users/kross/projects/ui/node_modules/@alienfast/babel-plugin-flow-react-proptypes/lib/makePropTypesAst.js:43:12)
at annotate (/Users/kross/projects/ui/node_modules/@alienfast/babel-plugin-flow-react-proptypes/lib/index.js:101:85)
at /Users/kross/projects/ui/node_modules/@alienfast/babel-plugin-flow-react-proptypes/lib/index.js:181:20
at Array.forEach (native)
at PluginPass.ClassDeclaration (/Users/kross/projects/ui/node_modules/@alienfast/babel-plugin-flow-react-proptypes/lib/index.js:178:29)
at newFn (/Users/kross/projects/ui/node_modules/babel-traverse/lib/visitors.js:266:21)
at NodePath._call (/Users/kross/projects/ui/node_modules/babel-traverse/lib/path/context.js:71:18)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:31 (27 by maintainers)
Top Results From Across the Web
flowtype coverage report is not picking up types I have already ...
1. Type already covered by flow-typed still not being used (Line #6) · 2. Custom library definition file not be picked up (Line...
Read more >Object Types - JavaScript. Flow
Exact object types are more precise and interact better with other type system features, like spreads. Object type syntax. Object types try to...
Read more >Adventures in Static Typing: React, Redux, Flow, Oh My
Use Object annotations, then replace with concrete types. E.g. { uuid: string } or reusable, domain-level types ( Reservation ); Define objects ......
Read more >Read more - GitHub
This includes the bigint type itself, subtyping with literals, libdefs, ... is present or that import types from other modules that use this...
Read more >How to incrementally add Flow to an existing React app
Flow [https://flow.org/] is a static type checker for Javascript. ... get ready for using libdefs created using the flow-typed NPM package.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I believe this fails due to the same root cause:
in
babel-plugin-flow-react-proptypes/lib/convertToPropTypes.js:165
,spreadShape.properties.forEach
explodes becausespreadShape
doesn’t have aproperties
property at all (possibly because it’s of typeGenericTypeAnnotation
?)@TSMMark that might happen if you have a type import (
import type ...
), since at the point the import is reached, we don’t know whether or not we need it at runtime. The import is modified such that the babel flow plugin won’t strip it, and then we can use it later if you refer to the type in a place that we process.