Skip to content

Commit d25ba18

Browse files
committed
Remove unnecessary Node types
1 parent 6d48e10 commit d25ba18

7 files changed

+11
-13
lines changed

Diff for: packages/react-docgen/src/handlers/componentDocblockHandler.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type Documentation from '../Documentation.js';
22
import { getDocblock } from '../utils/docblock.js';
33
import isReactForwardRefCall from '../utils/isReactForwardRefCall.js';
44
import resolveToValue from '../utils/resolveToValue.js';
5-
import type { NodePath, Node } from '@babel/traverse';
5+
import type { NodePath } from '@babel/traverse';
66
import type { ComponentNode } from '../resolver/index.js';
77
import type { Handler } from './index.js';
88

@@ -21,7 +21,7 @@ function getDocblockFromComponent(path: NodePath): string | null {
2121
}
2222
if (description == null) {
2323
// Find parent statement (e.g. var Component = React.createClass(<path>);)
24-
let searchPath: NodePath<Node> | null = path;
24+
let searchPath: NodePath | null = path;
2525

2626
while (searchPath && !searchPath.isStatement()) {
2727
searchPath = searchPath.parentPath;

Diff for: packages/react-docgen/src/handlers/defaultPropsHandler.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import type Documentation from '../Documentation.js';
99
import type { DefaultValueDescriptor } from '../Documentation.js';
1010
import type { NodePath } from '@babel/traverse';
1111
import type {
12-
Node,
1312
ObjectMethod,
1413
ObjectProperty,
1514
RestElement,
@@ -70,7 +69,7 @@ function getStatelessPropsPath(
7069
function getDefaultPropsPath(
7170
componentDefinition: NodePath<ComponentNode>,
7271
): NodePath | null {
73-
let defaultPropsPath: NodePath<Node> | null = getMemberValuePath(
72+
let defaultPropsPath: NodePath | null = getMemberValuePath(
7473
componentDefinition,
7574
'defaultProps',
7675
);

Diff for: packages/react-docgen/src/handlers/propDocblockHandler.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { NodePath } from '@babel/traverse';
2-
import type { Node } from '@babel/types';
32
import getMemberValuePath from '../utils/getMemberValuePath.js';
43
import resolveToValue from '../utils/resolveToValue.js';
54
import setPropDescription from '../utils/setPropDescription.js';
@@ -33,7 +32,7 @@ const propDocblockHandler: Handler = function (
3332
documentation: Documentation,
3433
componentDefinition: NodePath<ComponentNode>,
3534
): void {
36-
let propTypesPath: NodePath<Node> | null = getMemberValuePath(
35+
let propTypesPath: NodePath | null = getMemberValuePath(
3736
componentDefinition,
3837
'propTypes',
3938
);

Diff for: packages/react-docgen/src/handlers/propTypeCompositionHandler.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import resolveToModule from '../utils/resolveToModule.js';
33
import resolveToValue from '../utils/resolveToValue.js';
44
import type Documentation from '../Documentation.js';
55
import type { NodePath } from '@babel/traverse';
6-
import type { ObjectExpression, Node } from '@babel/types';
6+
import type { ObjectExpression } from '@babel/types';
77
import type { Handler } from './index.js';
88
import type { ComponentNode } from '../resolver/index.js';
99

@@ -37,7 +37,7 @@ const propTypeCompositionHandler: Handler = function (
3737
documentation: Documentation,
3838
componentDefinition: NodePath<ComponentNode>,
3939
): void {
40-
let propTypesPath: NodePath<Node> | null = getMemberValuePath(
40+
let propTypesPath: NodePath | null = getMemberValuePath(
4141
componentDefinition,
4242
'propTypes',
4343
);

Diff for: packages/react-docgen/src/handlers/propTypeHandler.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import resolveToValue from '../utils/resolveToValue.js';
99
import type Documentation from '../Documentation.js';
1010
import type { PropDescriptor, PropTypeDescriptor } from '../Documentation.js';
1111
import type { NodePath } from '@babel/traverse';
12-
import type { Node } from '@babel/types';
1312
import type { Handler } from './index.js';
1413
import type { ComponentNode } from '../resolver/index.js';
1514

@@ -65,7 +64,7 @@ function getPropTypeHandler(propName: string): Handler {
6564
documentation: Documentation,
6665
componentDefinition: NodePath<ComponentNode>,
6766
): void {
68-
let propTypesPath: NodePath<Node> | null = getMemberValuePath(
67+
let propTypesPath: NodePath | null = getMemberValuePath(
6968
componentDefinition,
7069
propName,
7170
);

Diff for: packages/react-docgen/src/utils/expressionTo.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/*eslint no-loop-func: 0, no-use-before-define: 0*/
22

33
import resolveToValue from './resolveToValue.js';
4-
import type { Node, NodePath } from '@babel/traverse';
4+
import type { NodePath } from '@babel/traverse';
5+
import type { Node } from '@babel/types';
56

67
/**
78
* Splits a MemberExpression or CallExpression into parts.

Diff for: packages/react-docgen/src/utils/isRequiredPropType.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import type { Node, NodePath } from '@babel/traverse';
1+
import type { NodePath } from '@babel/traverse';
22
import getMembers from '../utils/getMembers.js';
33

44
/**
55
* Returns true of the prop is required, according to its type definition
66
*/
7-
export default function isRequiredPropType(path: NodePath<Node>): boolean {
7+
export default function isRequiredPropType(path: NodePath): boolean {
88
return getMembers(path).some(
99
({ computed, path: memberPath }) =>
1010
(!computed && memberPath.isIdentifier({ name: 'isRequired' })) ||

0 commit comments

Comments
 (0)