All files / packages/design-system/ui/shared/helpers/prop-types cannot-be-set-with.js

100% Statements 7/7
100% Branches 8/8
100% Functions 2/2
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33      60x 49x 2844x 2408x   436x       1x                               435x        
// Copyright (c) 2015-present, salesforce.com, inc. All rights reserved
// Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license
 
const CannotBeSetWith = (dependentPropName, propType) => {
  return function(props, propName, componentName, ...rest) {
    if (props[propName] === undefined || props[propName] === null) {
      return;
    }
    if (
      props[dependentPropName] !== undefined &&
      props[dependentPropName] !== null
    ) {
      return new Error(
        'Invalid prop `' +
          propName +
          '` (has value `' +
          props[propName] +
          '`) supplied to `' +
          componentName +
          '`. Cannot set `' +
          dependentPropName +
          '` (has value `' +
          props[dependentPropName] +
          '`) when setting `' +
          propName +
          '`'
      );
    }
    return propType(props, propName, componentName, ...rest);
  };
};
export default CannotBeSetWith;