|
1 | 1 | /** |
2 | | - * Copyright IBM Corp. 2016, 2023 |
| 2 | + * Copyright IBM Corp. 2016, 2025 |
3 | 3 | * |
4 | 4 | * This source code is licensed under the Apache-2.0 license found in the |
5 | 5 | * LICENSE file in the root directory of this source tree. |
6 | 6 | */ |
7 | 7 |
|
| 8 | +import type { Requireable, Validator } from 'prop-types'; |
8 | 9 | import { warning } from '../internal/warning'; |
9 | 10 |
|
10 | | -const didWarnAboutDeprecation = {}; |
| 11 | +type DeprecationTracker = Record<string, Record<string, boolean>>; |
11 | 12 |
|
12 | | -export default function deprecateValuesWithin( |
13 | | - propType, |
14 | | - allowedValues, |
15 | | - propMappingFunction |
16 | | -) { |
17 | | - return function checker(props, propName, componentName, ...rest) { |
18 | | - if (props[propName] === undefined) { |
19 | | - return; |
| 13 | +const didWarnAboutDeprecation: DeprecationTracker = {}; |
| 14 | + |
| 15 | +export const deprecateValuesWithin = <T>( |
| 16 | + propType: Requireable<T>, |
| 17 | + allowedValues?: readonly unknown[], |
| 18 | + propMappingFunction?: (deprecatedValue: T) => T |
| 19 | +): Validator<T> | Requireable<T> => { |
| 20 | + return (props, propName, componentName, ...rest) => { |
| 21 | + if (typeof props[propName] === 'undefined') { |
| 22 | + return null; |
20 | 23 | } |
21 | 24 |
|
22 | 25 | if ( |
@@ -45,4 +48,4 @@ export default function deprecateValuesWithin( |
45 | 48 | } |
46 | 49 | return propType(props, propName, componentName, ...rest); |
47 | 50 | }; |
48 | | -} |
| 51 | +}; |
0 commit comments