Skip to content
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: facebook/prop-types
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v15.8.0
Choose a base ref
...
head repository: facebook/prop-types
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v15.8.1
Choose a head ref
  • 7 commits
  • 9 files changed
  • 2 contributors

Commits on Dec 23, 2021

  1. Verified

    This commit was signed with the committer’s verified signature.
    Copy the full SHA
    f9d2c19 View commit details

Commits on Dec 28, 2021

  1. [meta] Fix formatting in CHANGELOG.md

    wojtekmaj authored and ljharb committed Dec 28, 2021
    Copy the full SHA
    bdc31fa View commit details

Commits on Jan 4, 2022

  1. Copy the full SHA
    88e1b3d View commit details

Commits on Jan 5, 2022

  1. Copy the full SHA
    b93deca View commit details
  2. [Fix] fix crash when a custom propType return lacks .data; call `ha…

    …sOwnProperty` properly
    
    Fixes #369
    ljharb committed Jan 5, 2022
    Copy the full SHA
    90c8c47 View commit details
  3. [Dev Deps] update eslint

    ljharb committed Jan 5, 2022
    Copy the full SHA
    044efd7 View commit details
  4. v15.8.1

    ljharb committed Jan 5, 2022
    Copy the full SHA
    70330a4 View commit details
10 changes: 6 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -8,13 +8,15 @@ jobs:
name: "Build & Test (React v${{ matrix.react_version}})"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
react_version:
- "0.14.9"
- "15.0"
- "15"
- "16.0"
- "17"
- "16"
- "16.0"
- "15"
- "15.0"
- "0.14.9"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
52 changes: 30 additions & 22 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
## 15.8.1
* [Fix] fix crash when a custom propType return lacks `.data`; call `hasOwnProperty` properly (#370)
* [meta] Fix formatting in CHANGELOG.md (#367)
* [Tests] add missing test coverage (#370)
* [Tests] convert normal `it` functions to arrow functions (#370)
* [Tests] do not fail fast; add react 17 (#366)
* [Dev Deps] update `eslint`

## 15.8.0
[New] add `PropTypes.bigint` (#365)
[New] `oneOfType`: Add expected types to warning (#198)
[New] Add type check for validator for 'shape' and 'exact' (#234)
[Fix] `checkPropTypes`: Friendlier message when using a type checker that is not a function (#51)
[Refactor] extract `has` (#261, #125, #124)
[readme] Fix branch name (master -> main) (#364)
[readme] Clarify usage of `elementType` (#335)
[docs] highlighted the func name (#321)
[docs] Typo fix in example (#300)
[docs] Add instructions for intentional inclusion of validation in production. (#262)
[docs] `PropTypes.node`: add link to react docs
[docs] Improve wording for `checkPropTypes` (#258)
[meta] Add a package `sideEffects` field. (#350)
[meta] use `in-publish` to avoid running the build on install
[deps] regenerate yarn.lock
[deps] update `react-is` (#347, #346, #345, #340, #338)
[eslint] enable some rules (#360)
[Tests] Use GH Actions (#363)
[Tests] Fix spelling (#318)
[Tests] Fixed typo: 'Any type *should* accept any value' (#281)
[Tests] fix broken tests; test the build process
[Dev Deps] update `browserify`, `bundle-collapser`, `eslint`, `in-publish`, `react`, `uglifyify`, `uglifyjs`
* [New] add `PropTypes.bigint` (#365)
* [New] `oneOfType`: Add expected types to warning (#198)
* [New] Add type check for validator for 'shape' and 'exact' (#234)
* [Fix] `checkPropTypes`: Friendlier message when using a type checker that is not a function (#51)
* [Refactor] extract `has` (#261, #125, #124)
* [readme] Fix branch name (master -> main) (#364)
* [readme] Clarify usage of `elementType` (#335)
* [docs] highlighted the func name (#321)
* [docs] Typo fix in example (#300)
* [docs] Add instructions for intentional inclusion of validation in production. (#262)
* [docs] `PropTypes.node`: add link to react docs
* [docs] Improve wording for `checkPropTypes` (#258)
* [meta] Add a package `sideEffects` field. (#350)
* [meta] use `in-publish` to avoid running the build on install
* [deps] regenerate yarn.lock
* [deps] update `react-is` (#347, #346, #345, #340, #338)
* [eslint] enable some rules (#360)
* [Tests] Use GH Actions (#363)
* [Tests] Fix spelling (#318)
* [Tests] Fixed typo: 'Any type *should* accept any value' (#281)
* [Tests] fix broken tests; test the build process
* [Dev Deps] update `browserify`, `bundle-collapser`, `eslint`, `in-publish`, `react`, `uglifyify`, `uglifyjs`

## 15.7.2
* [Fix] ensure nullish values in `oneOf` do not crash ([#256](https://github.com/facebook/prop-types/issues/256))
31 changes: 31 additions & 0 deletions __tests__/PropTypesDevelopmentReact15.js
Original file line number Diff line number Diff line change
@@ -1385,6 +1385,37 @@ describe('PropTypesDevelopmentReact15', () => {
);
expectWarningInDevelopment(PropTypes.element, <div />);
});

it('works with oneOfType', () => {
typeCheckPass(
PropTypes.exact({ foo: PropTypes.oneOfType([PropTypes.number, PropTypes.string]) }),
{ foo: 42 }
);
typeCheckPass(
PropTypes.exact({ foo: PropTypes.oneOfType([PropTypes.number, PropTypes.string]) }),
{ foo: '42' }
);
typeCheckFail(
PropTypes.exact({ foo: PropTypes.oneOfType([PropTypes.number, PropTypes.string]) }),
{ foo: 42, bar: 'what is 6 * 7' },
`Warning: Failed prop type: Invalid prop \`testProp\` key \`bar\` supplied to \`testComponent\`.
Bad object: {
"foo": 42,
"bar": "what is 6 * 7"
}
Valid keys: [
"foo"
]`
);
});

it('works with a custom propType', () => {
typeCheckFail(
PropTypes.oneOfType([() => new Error('hi')]),
{},
'Warning: Failed prop type: Invalid prop `testProp` supplied to `testComponent`.'
)
});
});

describe('Symbol Type', () => {
135 changes: 135 additions & 0 deletions __tests__/PropTypesDevelopmentStandalone-test.js
Original file line number Diff line number Diff line change
@@ -1354,6 +1354,141 @@ describe('PropTypesDevelopmentStandalone', () => {
});
});

describe('Exact Types', () => {
it('should warn for non objects', () => {
spyOn(console, 'error');
expectThrowsInDevelopment(
PropTypes.exact({}),
'some string'
);
expectThrowsInDevelopment(
PropTypes.exact({}),
['array']
);
});

it('should not warn for empty values', () => {
typeCheckPass(PropTypes.exact({}), undefined);
typeCheckPass(PropTypes.exact({}), null);
typeCheckPass(PropTypes.exact({}), {});
});

it('should not warn for an empty object', () => {
typeCheckPass(PropTypes.exact({}).isRequired, {});
});

it('should warn for non specified types', () => {
typeCheckFail(
PropTypes.exact({}),
{key: 1},
'Warning: Failed prop type: Invalid prop `testProp` key `key` supplied to `testComponent`.' +
'\nBad object: {' +
'\n \"key\": 1' +
'\n}' +
'\nValid keys: []'
);
});

it('should not warn for valid types', () => {
typeCheckPass(PropTypes.exact({key: PropTypes.number}), {key: 1});
});

it('should warn for required valid types', () => {
typeCheckFail(
PropTypes.exact({key: PropTypes.number.isRequired}),
{},
'The prop `testProp.key` is marked as required in `testComponent`, ' +
'but its value is `undefined`.',
);
});

it('should warn for the first required type', () => {
typeCheckFail(
PropTypes.exact({
key: PropTypes.number.isRequired,
secondKey: PropTypes.number.isRequired,
}),
{},
'The prop `testProp.key` is marked as required in `testComponent`, ' +
'but its value is `undefined`.',
);
});

it('should warn for invalid key types', () => {
typeCheckFail(
PropTypes.exact({key: PropTypes.number}),
{key: 'abc'},
'Invalid prop `testProp.key` of type `string` supplied to `testComponent`, ' +
'expected `number`.',
);
});

it('should be implicitly optional and not warn without values', () => {
typeCheckPass(
PropTypes.exact(PropTypes.exact({key: PropTypes.number})),
null,
);
typeCheckPass(
PropTypes.exact(PropTypes.exact({key: PropTypes.number})),
undefined,
);
});

it('should warn for missing required values', () => {
typeCheckFailRequiredValues(
PropTypes.exact({key: PropTypes.number}).isRequired,
);
});

it('should warn if called manually in development', () => {
spyOn(console, 'error');
expectThrowsInDevelopment(PropTypes.exact({}), 'some string');
expectThrowsInDevelopment(PropTypes.exact({foo: PropTypes.number}), {
foo: 42,
});
expectThrowsInDevelopment(
PropTypes.exact({key: PropTypes.number}).isRequired,
null,
);
expectThrowsInDevelopment(
PropTypes.exact({key: PropTypes.number}).isRequired,
undefined,
);
expectThrowsInDevelopment(PropTypes.element, <div />);
});

it('works with oneOfType', () => {
typeCheckPass(
PropTypes.exact({ foo: PropTypes.oneOfType([PropTypes.number, PropTypes.string]) }),
{ foo: 42 }
);
typeCheckPass(
PropTypes.exact({ foo: PropTypes.oneOfType([PropTypes.number, PropTypes.string]) }),
{ foo: '42' }
);
typeCheckFail(
PropTypes.exact({ foo: PropTypes.oneOfType([PropTypes.number, PropTypes.string]) }),
{ foo: 42, bar: 'what is 6 * 7' },
`Warning: Failed prop type: Invalid prop \`testProp\` key \`bar\` supplied to \`testComponent\`.
Bad object: {
"foo": 42,
"bar": "what is 6 * 7"
}
Valid keys: [
"foo"
]`
);
});

it('works with a custom propType', () => {
typeCheckFail(
PropTypes.oneOfType([() => new Error('hi')]),
{},
'Warning: Failed prop type: Invalid prop `testProp` supplied to `testComponent`.'
)
});
});

describe('Symbol Type', () => {
it('should warn for non-symbol', () => {
typeCheckFail(
113 changes: 113 additions & 0 deletions __tests__/PropTypesProductionReact15-test.js
Original file line number Diff line number Diff line change
@@ -1023,6 +1023,119 @@ describe('PropTypesProductionReact15', () => {
});
});

describe('Exact Types', () => {
it('should warn for non objects', () => {
expectNoop(
PropTypes.exact({}),
'some string'
);
expectNoop(
PropTypes.exact({}),
['array']
);
});

it('should not warn for empty values', () => {
expectNoop(PropTypes.exact({}), undefined);
expectNoop(PropTypes.exact({}), null);
expectNoop(PropTypes.exact({}), {});
});

it('should not warn for an empty object', () => {
expectNoop(PropTypes.exact({}).isRequired, {});
});

it('expectNoop warn for non specified types', () => {
expectNoop(
PropTypes.exact({}),
{key: 1}
);
});

it('should not warn for valid types', () => {
expectNoop(PropTypes.exact({key: PropTypes.number}), {key: 1});
});

it('should warn for required valid types', () => {
expectNoop(
PropTypes.exact({key: PropTypes.number.isRequired}),
{}
);
});

it('should warn for the first required type', () => {
expectNoop(
PropTypes.exact({
key: PropTypes.number.isRequired,
secondKey: PropTypes.number.isRequired,
}),
{}
);
});

it('should warn for invalid key types', () => {
expectNoop(
PropTypes.exact({key: PropTypes.number}),
{key: 'abc'}
);
});

it('should be implicitly optional and not warn without values', () => {
expectNoop(
PropTypes.exact(PropTypes.exact({key: PropTypes.number})),
null,
);
expectNoop(
PropTypes.exact(PropTypes.exact({key: PropTypes.number})),
undefined,
);
});

it('should warn for missing required values', () => {
expectNoop(
PropTypes.exact({key: PropTypes.number}).isRequired,
);
});

it('should warn if called manually in development', () => {
expectNoop(PropTypes.exact({}), 'some string');
expectNoop(PropTypes.exact({foo: PropTypes.number}), {
foo: 42,
});
expectNoop(
PropTypes.exact({key: PropTypes.number}).isRequired,
null,
);
expectNoop(
PropTypes.exact({key: PropTypes.number}).isRequired,
undefined,
);
expectNoop(PropTypes.element, <div />);
});

it('works with oneOfType', () => {
expectNoop(
PropTypes.exact({ foo: PropTypes.oneOfType([PropTypes.number, PropTypes.string]) }),
{ foo: 42 }
);
expectNoop(
PropTypes.exact({ foo: PropTypes.oneOfType([PropTypes.number, PropTypes.string]) }),
{ foo: '42' }
);
expectNoop(
PropTypes.exact({ foo: PropTypes.oneOfType([PropTypes.number, PropTypes.string]) }),
{ foo: 42, bar: 'what is 6 * 7' }
);
});

it('works with a custom propType', () => {
expectNoop(
PropTypes.oneOfType([() => new Error('hi')]),
{}
)
});
});

describe('Symbol Type', () => {
it('should warn for non-symbol', () => {
expectNoop(
Loading