Skip to content

Commit 8688631

Browse files
Rename temporary variable (#167)
* 🔨 Renames temporary variable * docs(changeset): Minor variable rename and code formatting
1 parent c23cde1 commit 8688631

File tree

2 files changed

+19
-25
lines changed

2 files changed

+19
-25
lines changed

.changeset/three-camels-end.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'extract-react-types': patch
3+
---
4+
5+
Minor variable rename and code formatting

packages/extract-react-types/src/index.js

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -681,22 +681,14 @@ converters.Identifier = (path, context): K.Id => {
681681
? convert(path.get('typeAnnotation'), { ...context, mode: 'type' })
682682
: null;
683683

684-
return {
685-
kind: 'id',
686-
name,
687-
type
688-
};
684+
return { kind: 'id', name, type };
689685
}
690686
} else if (kind === 'static' || kind === 'binding') {
691687
const type = path.node.typeAnnotation
692688
? convert(path.get('typeAnnotation'), { ...context, mode: 'type' })
693689
: null;
694690

695-
return {
696-
kind: 'id',
697-
name,
698-
type
699-
};
691+
return { kind: 'id', name, type };
700692
} else {
701693
throw new Error(`Unable to resolve path for: ${kind}`);
702694
}
@@ -720,10 +712,7 @@ converters.Identifier = (path, context): K.Id => {
720712

721713
let tsBinding = getTypeBinding(path, name);
722714
if (!tsBinding) {
723-
return {
724-
kind: 'id',
725-
name
726-
};
715+
return { kind: 'id', name };
727716
}
728717
bindingPath = tsBinding.path.parentPath;
729718
} else {
@@ -1378,25 +1367,25 @@ function exportedComponents(programPath, componentsToFind: 'all' | 'default', co
13781367

13791368
if (isMemo || isForwardRef) {
13801369
// Props typed via generics
1381-
const genericTypeParams = path.get('typeParameters');
1370+
const genericParams = path.get('typeParameters');
13821371

13831372
// Props are the second type arg
1384-
if (isForwardRef && genericTypeParams.node) {
1373+
if (isForwardRef && genericParams.node) {
13851374
const component = convertReactComponentFunction(
1386-
genericTypeParams,
1375+
genericParams,
13871376
context,
1388-
genericTypeParams.get('params.1')
1377+
genericParams.get('params.1')
13891378
);
13901379

13911380
components.push({ name, path, component });
13921381
return;
13931382
}
13941383

1395-
if (isMemo && genericTypeParams.node) {
1384+
if (isMemo && genericParams.node) {
13961385
const component = convertReactComponentFunction(
1397-
genericTypeParams,
1386+
genericParams,
13981387
context,
1399-
genericTypeParams.get('params.0')
1388+
genericParams.get('params.0')
14001389
);
14011390

14021391
components.push({ name, path, component });
@@ -1417,17 +1406,17 @@ function exportedComponents(programPath, componentsToFind: 'all' | 'default', co
14171406
return;
14181407
}
14191408

1420-
const genericTypeParamsTEMP = firstArg.get('typeParameters');
1409+
const firstArgGenericParams = firstArg.get('typeParameters');
14211410

14221411
if (
14231412
isMemo &&
14241413
isSpecialReactComponentType(firstArg, 'forwardRef') &&
1425-
genericTypeParamsTEMP.node
1414+
firstArgGenericParams.node
14261415
) {
14271416
const component = convertReactComponentFunction(
1428-
genericTypeParams,
1417+
firstArgGenericParams,
14291418
context,
1430-
genericTypeParamsTEMP.get('params.1')
1419+
firstArgGenericParams.get('params.1')
14311420
);
14321421

14331422
components.push({ name, path, component });

0 commit comments

Comments
 (0)