Skip to content

Commit 0b37829

Browse files
fix(TreeItemCustom - TypeScript): omit content HTMLAttribute from PropTypes (#4476)
This PR also updates [@types/react to v18.0.34](fb280ac) --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent 0999a8e commit 0b37829

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

packages/main/scripts/create-web-components-wrapper.mjs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { renderComponentWrapper, renderTest } from '../../../scripts/web-compone
1717
import * as Utils from '../../../scripts/web-component-wrappers/utils.js';
1818
import {
1919
formatDemoDescription,
20+
getCommonPropsToBeOmitted,
2021
getDomRefGetters,
2122
getDomRefMethods,
2223
getDomRefObjects
@@ -283,15 +284,20 @@ const createWebComponentWrapper = async (
283284
const attributesToBeOmitted = [...regularProps, ...booleanProps]
284285
.filter((attribute) => KNOWN_ATTRIBUTES.has(attribute))
285286
.map((a) => `'${a}'`);
287+
const commonPropsToBeOmitted = getCommonPropsToBeOmitted(componentSpec.module);
286288

287289
let domRefExtends = 'Ui5DomRef';
288290
if (attributesToBeOmitted.length > 0) {
289291
domRefExtends = `Omit<Ui5DomRef, ${attributesToBeOmitted.join(' | ')}>`;
290292
}
291293

292294
let tsExtendsStatement = 'CommonProps';
293-
if (eventsToBeOmitted.length > 0 || attributesToBeOmitted.length > 0) {
294-
tsExtendsStatement = `Omit<CommonProps, ${[...attributesToBeOmitted, ...eventsToBeOmitted].join(' | ')}>`;
295+
if (eventsToBeOmitted.length > 0 || attributesToBeOmitted.length > 0 || commonPropsToBeOmitted.length > 0) {
296+
tsExtendsStatement = `Omit<CommonProps, ${[
297+
...attributesToBeOmitted,
298+
...eventsToBeOmitted,
299+
...commonPropsToBeOmitted
300+
].join(' | ')}>`;
295301
}
296302
let componentDescription;
297303
try {

packages/main/src/webComponents/TreeItemCustom/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export interface TreeItemCustomDomRef extends TreeItemCustomAttributes, Ui5DomRe
7272
toggle: () => void;
7373
}
7474

75-
export interface TreeItemCustomPropTypes extends TreeItemCustomAttributes, CommonProps {
75+
export interface TreeItemCustomPropTypes extends TreeItemCustomAttributes, Omit<CommonProps, 'content'> {
7676
/**
7777
* Defines the content of the `TreeItem`.
7878
*

scripts/web-component-wrappers/utils.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,3 +418,12 @@ export const formatDemoDescription = (description, componentSpec, replaceHeading
418418

419419
return prettier.format(formattedDescription, { ...prettierConfigRaw, parser: 'markdown' });
420420
};
421+
422+
export function getCommonPropsToBeOmitted(moduleName) {
423+
switch (moduleName) {
424+
case 'TreeItemCustom':
425+
return ["'content'"];
426+
default:
427+
return [];
428+
}
429+
}

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4805,13 +4805,13 @@ __metadata:
48054805
linkType: hard
48064806

48074807
"@types/react@npm:*, @types/react@npm:>=16, @types/react@npm:^18.0.6":
4808-
version: 18.0.31
4809-
resolution: "@types/react@npm:18.0.31"
4808+
version: 18.0.34
4809+
resolution: "@types/react@npm:18.0.34"
48104810
dependencies:
48114811
"@types/prop-types": "*"
48124812
"@types/scheduler": "*"
48134813
csstype: ^3.0.2
4814-
checksum: 6befbd5587e266905b50fd6bbd7c1cacd557bddf99e6a9862ca2f1d06df3dca71b9d485a37d010479730f021aab93b852d417c714de5efc2f41be0ff4c09b4db
4814+
checksum: 60d2766e7644ec480075bbb154bf8fb8476089466b643662ef59964e27cae2d8c71fd9c717a4dfa9627c3e050fa2ae866d10d16f66b4509058d1bfe2a564b18c
48154815
languageName: node
48164816
linkType: hard
48174817

0 commit comments

Comments
 (0)