Skip to content

Commit 0a11783

Browse files
authored
[Slider][material] Fix type dependency on @types/prop-types (#37853)
1 parent 47790b6 commit 0a11783

File tree

6 files changed

+27
-21
lines changed

6 files changed

+27
-21
lines changed

.circleci/config.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,6 @@ jobs:
269269
yarn workspace @mui/material typescript:module-augmentation
270270
yarn workspace @mui/base typescript:module-augmentation
271271
yarn workspace @mui/joy typescript:module-augmentation
272-
273-
- restore_cache:
274-
name: Restore generated declaration files
275-
keys:
276-
# #default-branch-switch
277-
# We assume that the target branch is `master` and that declaration files are persisted in commit order.
278-
# "If there are multiple matches, the most recently generated cache will be used."
279-
- typescript-declaration-files-master
280-
281272
- run:
282273
name: Diff declaration files
283274
command: |
@@ -286,7 +277,6 @@ jobs:
286277
git add -f packages/mui-utils/build || echo '/utils declarations do not exist'
287278
yarn lerna run build:types
288279
git --no-pager diff
289-
290280
- run:
291281
name: Any defect declaration files?
292282
command: node scripts/testBuiltTypes.mjs

packages/mui-material-next/src/Button/Ripple.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,6 @@ Ripple.propTypes = {
8585
* exit delay
8686
*/
8787
timeout: PropTypes.number.isRequired,
88-
};
88+
} as any;
8989

90-
export default Ripple;
90+
export default Ripple as (props: RippleProps) => JSX.Element;

packages/mui-material-next/src/Button/TouchRipple.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,6 @@ TouchRipple.propTypes = {
293293
* @ignore
294294
*/
295295
className: PropTypes.string,
296-
};
296+
} as any;
297297

298298
export default TouchRipple;

packages/mui-material-next/src/Slider/Slider.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ SliderRoot.propTypes /* remove-proptypes */ = {
105105
* @ignore
106106
*/
107107
children: PropTypes.node,
108-
};
108+
} as any;
109109

110110
export { SliderRoot };
111111

@@ -145,7 +145,7 @@ SliderRail.propTypes /* remove-proptypes */ = {
145145
* @ignore
146146
*/
147147
children: PropTypes.node,
148-
};
148+
} as any;
149149

150150
export { SliderRail };
151151

@@ -193,7 +193,7 @@ SliderTrack.propTypes /* remove-proptypes */ = {
193193
* @ignore
194194
*/
195195
children: PropTypes.node,
196-
};
196+
} as any;
197197

198198
export { SliderTrack };
199199

@@ -294,7 +294,7 @@ SliderThumb.propTypes /* remove-proptypes */ = {
294294
* @ignore
295295
*/
296296
children: PropTypes.node,
297-
};
297+
} as any;
298298

299299
export { SliderThumb };
300300

@@ -391,7 +391,7 @@ SliderValueLabel.propTypes /* remove-proptypes */ = {
391391
* @ignore
392392
*/
393393
children: PropTypes.element,
394-
};
394+
} as any;
395395

396396
export { SliderValueLabel };
397397

@@ -438,7 +438,7 @@ SliderMark.propTypes /* remove-proptypes */ = {
438438
* @ignore
439439
*/
440440
children: PropTypes.node,
441-
};
441+
} as any;
442442

443443
export { SliderMark };
444444

@@ -490,7 +490,7 @@ SliderMarkLabel.propTypes /* remove-proptypes */ = {
490490
* @ignore
491491
*/
492492
children: PropTypes.node,
493-
};
493+
} as any;
494494

495495
export { SliderMarkLabel };
496496

packages/mui-material/src/Slider/SliderValueLabel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ SliderValueLabel.propTypes = {
5050
children: PropTypes.element.isRequired,
5151
className: PropTypes.string,
5252
value: PropTypes.node,
53-
};
53+
} as any;

scripts/buildTypes.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ async function main() {
5454

5555
async function rewriteImportPaths(declarationFile) {
5656
const code = await fse.readFile(declarationFile, { encoding: 'utf8' });
57+
const basename = path.basename(declarationFile);
58+
59+
if (
60+
// Only consider React components
61+
basename[0] === basename[0].toUpperCase() &&
62+
code.indexOf("import PropTypes from 'prop-types';") !== -1
63+
) {
64+
throw new Error(
65+
[
66+
`${declarationFile} imports from 'prop-types', this is wrong.`,
67+
"It's likely missing a cast to any on the propTypes declaration:",
68+
'ComponentName.propTypes = { /* prop */ } as any;',
69+
].join('\n'),
70+
);
71+
}
72+
5773
let fixedCode = code;
5874
const changes = [];
5975

0 commit comments

Comments
 (0)