Files
LifeTrinket/template.js
2024-08-31 20:11:10 +02:00

41 lines
762 B
JavaScript

const propTypesTemplate = (
{ interfaces, componentName, props, jsx },
{ tpl }
) => {
const title = componentName.split('Svg')[1];
interfaces[0].body.body.push({
type: 'TSPropertySignature',
key: { type: 'Identifier', name: 'size' },
typeAnnotation: {
type: 'TSTypeAnnotation',
typeAnnotation: {
type: 'TSStringKeyword',
},
},
initializer: null,
optional: true,
});
return tpl`
import PropTypes from 'prop-types';
import { SVGProps } from "react";
${interfaces}
const ${title} = (${props}) => {
return ${jsx};
}
${title}.propTypes = {
title: PropTypes.string,
};
export default ${title}`;
};
// eslint-disable-next-line no-undef
module.exports = propTypesTemplate;