Migrate Block Title component to TypeScript (https://github.com/woocommerce/woocommerce-blocks/pull/9712)
Co-authored-by: Niels Lange <info@nielslange.de> Co-authored-by: Alba Rincón <albarin@users.noreply.github.com> Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
This commit is contained in:
parent
9f87afde32
commit
563b439f25
|
@ -1,7 +1,6 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import PropTypes from 'prop-types';
|
||||
import { PlainText } from '@wordpress/block-editor';
|
||||
import { withInstanceId } from '@wordpress/compose';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
|
@ -10,15 +9,21 @@ import { __ } from '@wordpress/i18n';
|
|||
* Internal dependencies
|
||||
*/
|
||||
import './editor.scss';
|
||||
|
||||
interface BlockTitleProps {
|
||||
className: string;
|
||||
headingLevel: number;
|
||||
onChange: ( value: string ) => void;
|
||||
heading: string;
|
||||
instanceId: number;
|
||||
}
|
||||
const BlockTitle = ( {
|
||||
className,
|
||||
headingLevel,
|
||||
onChange,
|
||||
heading,
|
||||
instanceId,
|
||||
} ) => {
|
||||
const TagName = `h${ headingLevel }`;
|
||||
}: BlockTitleProps ) => {
|
||||
const TagName = `h${ headingLevel }` as keyof JSX.IntrinsicElements;
|
||||
return (
|
||||
<TagName className={ className }>
|
||||
<label
|
||||
|
@ -38,23 +43,4 @@ const BlockTitle = ( {
|
|||
);
|
||||
};
|
||||
|
||||
BlockTitle.propTypes = {
|
||||
/**
|
||||
* Classname to add to title in addition to the defaults.
|
||||
*/
|
||||
className: PropTypes.string,
|
||||
/**
|
||||
* The value of the heading.
|
||||
*/
|
||||
value: PropTypes.string,
|
||||
/**
|
||||
* Callback to update the attribute when text is changed.
|
||||
*/
|
||||
onChange: PropTypes.func,
|
||||
/**
|
||||
* Level of the heading tag (1, 2, 3... will render <h1>, <h2>, <h3>... elements).
|
||||
*/
|
||||
headingLevel: PropTypes.number,
|
||||
};
|
||||
|
||||
export default withInstanceId( BlockTitle );
|
|
@ -1982,7 +1982,7 @@
|
|||
<error line="174" column="35" severity="error" message="Argument of type 'unknown' is not assignable to parameter of type 'StoreAttributes[]'." source="TS2345" />
|
||||
<error line="182" column="35" severity="error" message="Parameter 'attribute' implicitly has an 'any' type." source="TS7006" />
|
||||
</file>
|
||||
<file name="assets/js/editor-components/block-title/index.js">
|
||||
<file name="assets/js/editor-components/block-title/index.tsx">
|
||||
<error line="15" column="2" severity="error" message="Binding element 'className' implicitly has an 'any' type." source="TS7031" />
|
||||
<error line="16" column="2" severity="error" message="Binding element 'headingLevel' implicitly has an 'any' type." source="TS7031" />
|
||||
<error line="17" column="2" severity="error" message="Binding element 'onChange' implicitly has an 'any' type." source="TS7031" />
|
||||
|
|
Loading…
Reference in New Issue