brigand / brigand/babel-plugin-flow-react-proptypes

Using built-in generics in a generic type fails

Open
#217 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
427
Forks
42
PR merge metrics
No merged PRs in 30d

Description

The following code:
```
type MyType = Array;

export type Props = {
numbers: MyType,
};
```
results in the following error:
```
TypeError: internalTypes[node.id.name] is not a function

49 | else if (node.type === 'GenericTypeAnnotation' && node.typeParameters) {
50 | const realTypeParameters = node.typeParameters.params.map(p => mapGenericToRealType(p, typeParamMapping));
> 51 | return internalTypes[node.id.name](realTypeParameters);
| ^
52 | }
53 | else if (node.type === 'ArrayTypeAnnotation') {
54 | const realElementType = mapGenericToRealType(node.elementType, typeParamMapping);

at convertGenericToPropTypes (src/convertToPropTypes.js:51:12)
...
```
I put a break point there and discovered that `"Array"` is not a key of `internalTypes` and this is what was triggering the failure.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.