diff --git a/packages/react-docgen/src/handlers/defaultPropsHandler.ts b/packages/react-docgen/src/handlers/defaultPropsHandler.ts index 57e9f743f4e..d1a88218d59 100644 --- a/packages/react-docgen/src/handlers/defaultPropsHandler.ts +++ b/packages/react-docgen/src/handlers/defaultPropsHandler.ts @@ -15,9 +15,11 @@ import type { RestElement, SpreadElement, } from '@babel/types'; -import type { ComponentNode } from '../resolver/index.js'; +import type { + ComponentNode, + StatelessComponentNode, +} from '../resolver/index.js'; import type { Handler } from './index.js'; -import type { StatelessComponentNode } from '../resolver/index.js'; function getDefaultValue(path: NodePath): DefaultValueDescriptor | null { let defaultValue: string | undefined; @@ -57,7 +59,7 @@ function getDefaultValue(path: NodePath): DefaultValueDescriptor | null { } function getStatelessPropsPath( - componentDefinition: NodePath, + componentDefinition: NodePath, ): NodePath | undefined { let value: NodePath = componentDefinition; @@ -165,7 +167,7 @@ const defaultPropsHandler: Handler = function ( */ if (!isReactComponentClass(componentDefinition)) { statelessProps = getStatelessPropsPath( - componentDefinition as NodePath, + componentDefinition as NodePath, ); } diff --git a/packages/react-docgen/src/utils/flowUtilityTypes.ts b/packages/react-docgen/src/utils/flowUtilityTypes.ts index 23a3c5dc8ac..f0c55aeb480 100644 --- a/packages/react-docgen/src/utils/flowUtilityTypes.ts +++ b/packages/react-docgen/src/utils/flowUtilityTypes.ts @@ -28,11 +28,14 @@ export function isSupportedUtilityType( */ export function unwrapUtilityType(path: NodePath): NodePath { let resultPath: NodePath = path; + while (isSupportedUtilityType(resultPath)) { const typeParameters = resultPath.get('typeParameters'); + if (!typeParameters.hasNode()) break; const firstParam = typeParameters.get('params')[0]; + if (!firstParam) break; resultPath = firstParam; diff --git a/packages/react-docgen/src/utils/getFlowType.ts b/packages/react-docgen/src/utils/getFlowType.ts index 88673c43b6a..96b76662e90 100644 --- a/packages/react-docgen/src/utils/getFlowType.ts +++ b/packages/react-docgen/src/utils/getFlowType.ts @@ -53,6 +53,7 @@ const flowLiteralTypes = { const namedTypes: Record< string, ( + // eslint-disable-next-line @typescript-eslint/no-explicit-any path: NodePath, typeParams: TypeParameters | null, ) => TypeDescriptor | null diff --git a/packages/react-docgen/src/utils/getTSType.ts b/packages/react-docgen/src/utils/getTSType.ts index 2c6f9032376..c60b4a30361 100644 --- a/packages/react-docgen/src/utils/getTSType.ts +++ b/packages/react-docgen/src/utils/getTSType.ts @@ -58,6 +58,7 @@ const tsTypes: Record = { const namedTypes: Record< string, ( + // eslint-disable-next-line @typescript-eslint/no-explicit-any path: NodePath, typeParams: TypeParameters | null, ) => TypeDescriptor | null diff --git a/packages/react-docgen/src/utils/isReactChildrenElementCall.ts b/packages/react-docgen/src/utils/isReactChildrenElementCall.ts index 252817fa1be..4c22fdb012a 100644 --- a/packages/react-docgen/src/utils/isReactChildrenElementCall.ts +++ b/packages/react-docgen/src/utils/isReactChildrenElementCall.ts @@ -1,7 +1,7 @@ import type { NodePath } from '@babel/traverse'; import isReactModuleName from './isReactModuleName.js'; import resolveToModule from './resolveToModule.js'; -import { CallExpression } from '@babel/types'; +import type { CallExpression } from '@babel/types'; /** * Returns true if the expression is a function call of the form diff --git a/packages/react-docgen/src/utils/isReactCreateClassCall.ts b/packages/react-docgen/src/utils/isReactCreateClassCall.ts index a7742625f8e..21b6d4f7f58 100644 --- a/packages/react-docgen/src/utils/isReactCreateClassCall.ts +++ b/packages/react-docgen/src/utils/isReactCreateClassCall.ts @@ -1,7 +1,7 @@ import type { NodePath } from '@babel/traverse'; import resolveToModule from './resolveToModule.js'; import isReactBuiltinCall from './isReactBuiltinCall.js'; -import { CallExpression } from '@babel/types'; +import type { CallExpression } from '@babel/types'; /** * Returns true if the expression is a function call of the form diff --git a/packages/react-docgen/src/utils/isReactForwardRefCall.ts b/packages/react-docgen/src/utils/isReactForwardRefCall.ts index dda67a9f68c..c46802aaf9f 100644 --- a/packages/react-docgen/src/utils/isReactForwardRefCall.ts +++ b/packages/react-docgen/src/utils/isReactForwardRefCall.ts @@ -1,6 +1,6 @@ import type { NodePath } from '@babel/traverse'; import isReactBuiltinCall from './isReactBuiltinCall.js'; -import { CallExpression } from '@babel/types'; +import type { CallExpression } from '@babel/types'; /** * Returns true if the expression is a function call of the form