Skip to content

Commit

Permalink
Rename temporary variable (#167)
Browse files Browse the repository at this point in the history
* 🔨 Renames temporary variable

* docs(changeset): Minor variable rename and code formatting
  • Loading branch information
danieldelcore authored Mar 3, 2021
1 parent c23cde1 commit 8688631
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
5 changes: 5 additions & 0 deletions .changeset/three-camels-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'extract-react-types': patch
---

Minor variable rename and code formatting
39 changes: 14 additions & 25 deletions packages/extract-react-types/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,22 +681,14 @@ converters.Identifier = (path, context): K.Id => {
? convert(path.get('typeAnnotation'), { ...context, mode: 'type' })
: null;

return {
kind: 'id',
name,
type
};
return { kind: 'id', name, type };
}
} else if (kind === 'static' || kind === 'binding') {
const type = path.node.typeAnnotation
? convert(path.get('typeAnnotation'), { ...context, mode: 'type' })
: null;

return {
kind: 'id',
name,
type
};
return { kind: 'id', name, type };
} else {
throw new Error(`Unable to resolve path for: ${kind}`);
}
Expand All @@ -720,10 +712,7 @@ converters.Identifier = (path, context): K.Id => {

let tsBinding = getTypeBinding(path, name);
if (!tsBinding) {
return {
kind: 'id',
name
};
return { kind: 'id', name };
}
bindingPath = tsBinding.path.parentPath;
} else {
Expand Down Expand Up @@ -1378,25 +1367,25 @@ function exportedComponents(programPath, componentsToFind: 'all' | 'default', co

if (isMemo || isForwardRef) {
// Props typed via generics
const genericTypeParams = path.get('typeParameters');
const genericParams = path.get('typeParameters');

// Props are the second type arg
if (isForwardRef && genericTypeParams.node) {
if (isForwardRef && genericParams.node) {
const component = convertReactComponentFunction(
genericTypeParams,
genericParams,
context,
genericTypeParams.get('params.1')
genericParams.get('params.1')
);

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

if (isMemo && genericTypeParams.node) {
if (isMemo && genericParams.node) {
const component = convertReactComponentFunction(
genericTypeParams,
genericParams,
context,
genericTypeParams.get('params.0')
genericParams.get('params.0')
);

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

const genericTypeParamsTEMP = firstArg.get('typeParameters');
const firstArgGenericParams = firstArg.get('typeParameters');

if (
isMemo &&
isSpecialReactComponentType(firstArg, 'forwardRef') &&
genericTypeParamsTEMP.node
firstArgGenericParams.node
) {
const component = convertReactComponentFunction(
genericTypeParams,
firstArgGenericParams,
context,
genericTypeParamsTEMP.get('params.1')
firstArgGenericParams.get('params.1')
);

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

0 comments on commit 8688631

Please sign in to comment.