Skip to content

Commit

Permalink
fix: type annotation in generated <Icon />
Browse files Browse the repository at this point in the history
  • Loading branch information
r17x committed Sep 7, 2021
1 parent e2526ad commit 8534d35
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions lib/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ const hastToComponent = (hast, { displayName, isTypescript }) => {

const propsIdentifier = t.identifier("props");

if (isTypescript) {
propsIdentifier.typeAnnotation = t.tsTypeAnnotation(
t.tsTypeReference(t.identifier("IconProps"))
);
}

const iconElement = addOpeningAttributes(
expressionStatement,
t.jsxSpreadAttribute(propsIdentifier)
Expand All @@ -264,11 +270,6 @@ const hastToComponent = (hast, { displayName, isTypescript }) => {
// @see {https://babeljs.io/docs/en/babel-types#variabledeclarator}
const variableIdentifier = t.identifier(displayName);

if (isTypescript) {
variableIdentifier.typeAnnotation = t.tsTypeAnnotation(
t.tsTypeReference(t.identifier("IconProps"))
);
}
const variableDeclarator = t.variableDeclarator(
variableIdentifier,
arrowFunctionIcon
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-chakra-icons",
"version": "1.0.0",
"version": "1.0.1",
"description": "Transform SVG to React Chakra UI <Icon /> ✨",
"author": "ri7nz <hi@rin.rocks>",
"license": "MIT",
Expand Down

0 comments on commit 8534d35

Please sign in to comment.