Blame view

天文台pc/tianwentai-ui/node_modules/@mui/utils/esm/exactProp/exactProp.js 759 Bytes
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  // This module is based on https://github.com/airbnb/prop-types-exact repository.
  // However, in order to reduce the number of dependencies and to remove some extra safe checks
  // the module was forked.
  
  const specialProperty = 'exact-prop: \u200b';
  export default function exactProp(propTypes) {
    if (process.env.NODE_ENV === 'production') {
      return propTypes;
    }
    return {
      ...propTypes,
      [specialProperty]: props => {
        const unsupportedProps = Object.keys(props).filter(prop => !propTypes.hasOwnProperty(prop));
        if (unsupportedProps.length > 0) {
          return new Error(`The following props are not supported: ${unsupportedProps.map(prop => `\`${prop}\``).join(', ')}. Please remove them.`);
        }
        return null;
      }
    };
  }