Skip to content

Commit 762cc92

Browse files
committed
implemented fix to flow recursive struct error
1 parent c73fbb9 commit 762cc92

File tree

5 files changed

+92
-0
lines changed

5 files changed

+92
-0
lines changed

src/__tests__/__snapshots__/main-test.js.snap

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,3 +1465,54 @@ Object {
14651465
},
14661466
}
14671467
`;
1468+
1469+
exports[`main fixtures processes component "component_29.js" without errors 1`] = `
1470+
Object {
1471+
"description": "",
1472+
"displayName": "MyComponent",
1473+
"methods": Array [],
1474+
"props": Object {
1475+
"prop": Object {
1476+
"description": "",
1477+
"flowType": Object {
1478+
"name": "T",
1479+
},
1480+
"required": true,
1481+
},
1482+
},
1483+
}
1484+
`;
1485+
1486+
exports[`main fixtures processes component "component_30.js" without errors 1`] = `
1487+
Object {
1488+
"description": "",
1489+
"displayName": "MyComponent",
1490+
"methods": Array [],
1491+
"props": Object {
1492+
"prop": Object {
1493+
"description": "",
1494+
"flowType": Object {
1495+
"name": "string",
1496+
},
1497+
"required": true,
1498+
},
1499+
},
1500+
}
1501+
`;
1502+
1503+
exports[`main fixtures processes component "component_31.js" without errors 1`] = `
1504+
Object {
1505+
"description": "",
1506+
"displayName": "MyComponent",
1507+
"methods": Array [],
1508+
"props": Object {
1509+
"prop": Object {
1510+
"description": "",
1511+
"flowType": Object {
1512+
"name": "T",
1513+
},
1514+
"required": true,
1515+
},
1516+
},
1517+
}
1518+
`;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from "react";
2+
3+
type Identity<T> = T;
4+
5+
type Props<T> = {
6+
prop: Identity<T>,
7+
}
8+
9+
export default function MyComponent<T>(props: Props<T>) {
10+
return <div>Hello World</div>
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from "react";
2+
3+
type Identity<T> = T;
4+
5+
type Props = {
6+
prop: Identity<string>,
7+
}
8+
9+
export default function MyComponent(props: Props) {
10+
return <div>Hello World</div>
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from "react";
2+
3+
type Identity<T> = T;
4+
5+
type Props<T> = {
6+
prop: Identity<Identity<T>>,
7+
}
8+
9+
export default function MyComponent<T>(props: Props<T>) {
10+
return <div>Hello World</div>
11+
}

src/utils/getFlowType.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ function handleGenericTypeAnnotation(
139139
);
140140
}
141141

142+
if (
143+
typeParams &&
144+
typeParams[type.name] &&
145+
typeParams[type.name].value.type === t.GenericTypeAnnotation.name
146+
) {
147+
return type;
148+
}
149+
142150
if (typeParams && typeParams[type.name]) {
143151
type = getFlowTypeWithResolvedTypes(resolvedPath, typeParams);
144152
}

0 commit comments

Comments
 (0)