Skip to content

Commit b6bde2d

Browse files
committed
Fix some any type warnings
1 parent ea495c4 commit b6bde2d

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

packages/react-docgen/src/Documentation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ export default class DocumentationBuilder {
203203
const obj: Documentation = {};
204204

205205
for (const [key, value] of this.#data) {
206+
// @ts-expect-error The types for Documentation do not allow to be extended atm
206207
obj[key] = value;
207208
}
208209

packages/react-docgen/src/utils/flowUtilityTypes.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ export function isSupportedUtilityType(
2828
*/
2929
export function unwrapUtilityType(path: NodePath): NodePath {
3030
while (isSupportedUtilityType(path)) {
31-
path = path.get('typeParameters').get('params')[0];
31+
const typeParameters = path.get('typeParameters');
32+
33+
if (!typeParameters.hasNode()) break;
34+
35+
const param = typeParameters.get('params')[0];
36+
37+
if (!param) break;
38+
39+
path = param;
3240
}
3341

3442
return path;

packages/react-docgen/src/utils/getPropType.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ function getPropTypeShapish(
170170
}
171171

172172
if (argumentPath.isObjectExpression()) {
173-
let value: Record<string, PropTypeDescriptor> | string = {};
173+
const value: Record<string, PropTypeDescriptor> = {};
174+
let rawValue: string | undefined;
174175

175176
argumentPath.get('properties').forEach((propertyPath) => {
176177
// We only handle ObjectProperty as there is nothing to handle for
@@ -186,7 +187,7 @@ function getPropTypeShapish(
186187
// This indicates we have a cyclic reference in the shape
187188
// In this case we simply print the argument to shape and bail
188189
if (argument && isCyclicReference(argument, argumentPath)) {
189-
value = printValue(argument);
190+
rawValue = printValue(argument);
190191

191192
return;
192193
}
@@ -202,7 +203,7 @@ function getPropTypeShapish(
202203
}
203204
});
204205

205-
type.value = value;
206+
type.value = rawValue ?? value;
206207
}
207208

208209
return type;

0 commit comments

Comments
 (0)