From 66a0ee5d4e8c57af4b244ff1659961ef50594972 Mon Sep 17 00:00:00 2001 From: HarelM Date: Thu, 21 Dec 2023 09:23:06 +0200 Subject: [PATCH] Initial migration of jsx files --- src/components/{Doc.jsx => Doc.tsx} | 38 +++++++++++------- .../{InputButton.jsx => InputButton.tsx} | 30 +++++++------- .../{InputCheckbox.jsx => InputCheckbox.tsx} | 16 ++++---- .../{InputSelect.jsx => InputSelect.tsx} | 26 ++++++------ .../{InputString.jsx => InputString.tsx} | 40 ++++++++++--------- .../{SmallError.jsx => SmallError.tsx} | 13 +++--- 6 files changed, 84 insertions(+), 79 deletions(-) rename src/components/{Doc.jsx => Doc.tsx} (80%) rename src/components/{InputButton.jsx => InputButton.tsx} (53%) rename src/components/{InputCheckbox.jsx => InputCheckbox.tsx} (77%) rename src/components/{InputSelect.jsx => InputSelect.tsx} (53%) rename src/components/{InputString.jsx => InputString.tsx} (70%) rename src/components/{SmallError.jsx => SmallError.tsx} (54%) diff --git a/src/components/Doc.jsx b/src/components/Doc.tsx similarity index 80% rename from src/components/Doc.jsx rename to src/components/Doc.tsx index 3285165c..c5db0c4d 100644 --- a/src/components/Doc.jsx +++ b/src/components/Doc.tsx @@ -1,24 +1,33 @@ import React from 'react' -import PropTypes from 'prop-types' -export default class Doc extends React.Component { - static propTypes = { - fieldSpec: PropTypes.object.isRequired, +const headers = { + js: "JS", + android: "Android", + ios: "iOS", + macos: "macOS", +}; + +type DocProps = { + fieldSpec: { + doc?: string + values?: { + [key: string]: { + doc?: string + } + } + 'sdk-support'?: { + [key: string]: typeof headers + } } +}; +export default class Doc extends React.Component { render () { const {fieldSpec} = this.props; const {doc, values} = fieldSpec; const sdkSupport = fieldSpec['sdk-support']; - const headers = { - js: "JS", - android: "Android", - ios: "iOS", - macos: "macOS", - }; - const renderValues = ( !!values && // HACK: Currently we merge additional values into the style spec, so this is required @@ -61,10 +70,9 @@ export default class Doc extends React.Component { return ( {key} - {Object.keys(headers).map(k => { - const value = supportObj[k]; + {Object.keys(headers).map((k) => { if (supportObj.hasOwnProperty(k)) { - return {supportObj[k]}; + return {supportObj[k as keyof typeof headers]}; } else { return no; @@ -80,4 +88,4 @@ export default class Doc extends React.Component { ); } -} +} \ No newline at end of file diff --git a/src/components/InputButton.jsx b/src/components/InputButton.tsx similarity index 53% rename from src/components/InputButton.jsx rename to src/components/InputButton.tsx index e9c4b235..bd8aaaa1 100644 --- a/src/components/InputButton.jsx +++ b/src/components/InputButton.tsx @@ -1,21 +1,20 @@ import React from 'react' -import PropTypes from 'prop-types' import classnames from 'classnames' -export default class InputButton extends React.Component { - static propTypes = { - "data-wd-key": PropTypes.string, - "aria-label": PropTypes.string, - onClick: PropTypes.func, - style: PropTypes.object, - className: PropTypes.string, - children: PropTypes.node, - disabled: PropTypes.bool, - type: PropTypes.string, - id: PropTypes.string, - title: PropTypes.string, - } +type InputButtonProps = { + "data-wd-key"?: string + "aria-label"?: string + onClick?(...args: unknown[]): unknown + style?: object + className?: string + children?: React.ReactNode + disabled?: boolean + type?: typeof HTMLButtonElement.prototype.type + id?: string + title?: string +}; +export default class InputButton extends React.Component { render() { return