Skip to content

Commit a1832da

Browse files
committed
fix FormItem typings
1 parent 24e973c commit a1832da

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

packages/main/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"build:i18n-default": "node ../../node_modules/@ui5/webcomponents-tools/lib/i18n/defaults.js src/i18n dist/assets/i18n && tsc dist/assets/i18n/i18n-defaults.js --allowJs --declaration --emitDeclarationOnly --declarationDir dist/assets/i18n",
3030
"build:i18n-imports": "mkdirp dist/json-imports && node ../../node_modules/@ui5/webcomponents-tools/lib/generate-json-imports/i18n.js dist/assets/i18n dist/json-imports/",
3131
"build:assets": "node ../../scripts/generate-assets/index.js",
32-
"build:types": "tsc --declaration --emitDeclarationOnly --declarationDir . --removeComments false || exit 0"
32+
"build:types": "tsc --declaration --emitDeclarationOnly --declarationDir . --removeComments false"
3333
},
3434
"dependencies": {
3535
"@babel/runtime": "7.11.0",

packages/main/src/components/FormItem/index.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createComponentStyles } from '@ui5/webcomponents-react-base/lib/createC
22
import { FlexBox } from '@ui5/webcomponents-react/lib/FlexBox';
33
import { FlexBoxAlignItems } from '@ui5/webcomponents-react/lib/FlexBoxAlignItems';
44
import { FlexBoxDirection } from '@ui5/webcomponents-react/lib/FlexBoxDirection';
5-
import { Label } from '@ui5/webcomponents-react/lib/Label';
5+
import { Label, LabelPropTypes } from '@ui5/webcomponents-react/lib/Label';
66
import React, { cloneElement, CSSProperties, FC, isValidElement, ReactElement, ReactNode, ReactNodeArray } from 'react';
77

88
export interface FormItemProps {
@@ -50,18 +50,21 @@ const renderLabel = (
5050
}
5151

5252
if (isValidElement(label)) {
53-
return cloneElement(
53+
return cloneElement<LabelPropTypes>(
5454
label,
5555
{
56-
wrap: label.props.wrap ?? true,
57-
className: `${classes.label} ${label.props.className ?? ''}`,
56+
wrap: (label as ReactElement<LabelPropTypes>).props.wrap ?? true,
57+
className: `${classes.label} ${(label as ReactElement<LabelPropTypes>).props.className ?? ''}`,
5858
style: {
5959
gridColumnStart: styles.gridColumnStart,
6060
gridRowStart: styles.gridRowStart,
61-
...(label.props.style || {})
61+
...((label as ReactElement<LabelPropTypes>).props.style || {})
6262
}
6363
},
64-
label.props.children ? `${label.props.children}:` : ''
64+
(label as ReactElement<LabelPropTypes>).props.children
65+
? // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
66+
`${(label as ReactElement<LabelPropTypes>).props.children}:`
67+
: ''
6568
);
6669
}
6770

0 commit comments

Comments
 (0)