-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Adds support for React.FC & FC (#183)
* ✨ Adds support for React.FC & FC * docs(changeset): Adds support for React.FC and FC
- Loading branch information
1 parent
0b9456e
commit 7a46827
Showing
5 changed files
with
135 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'extract-react-types': patch | ||
--- | ||
|
||
Adds support for React.FC and FC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
|
||
export function hasTypeAnnotation(path, left, right) { | ||
if (!path.isVariableDeclarator() || !path.node.id.typeAnnotation) { | ||
return false; | ||
} | ||
|
||
const { typeName, typeParameters } = path.node.id.typeAnnotation.typeAnnotation; | ||
|
||
if (!typeParameters) return false; | ||
|
||
if ( | ||
(typeName.left && typeName.left.name === left && typeName.right.name === right) || | ||
((right && typeName.name === right) || typeName.name === left) | ||
) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} |