ljharb/prop-types-exact

For use with React PropTypes. Will error on any prop not explicitly specified.

JavaScript

237

101 commits

updated Apr 30, 2026

See the code

README

prop-types-exact Version Badge

github actions coverage License Downloads

npm badge

For use with React PropTypes. Will error on any prop not explicitly specified.

Usage

import PropTypes from 'prop-types';
import exact from 'prop-types-exact';

function Foo({ foo, bar }) {
  return <div>{foo}{bar}</div>
}
Foo.propTypes = exact({
  foo: PropTypes.string,
  bar: PropTypes.number,
});

<Foo foo="hi" bar={3} /> // no warnings

<Foo foo="hi" bar={3} baz="extra" /> // propTypes warning!

Tests

Simply clone the repo, npm install, and run npm test

Contributors

ljharb

100 commits

jackwilsdon

1 commits

ljharb/prop-types-exact

For use with React PropTypes. Will error on any prop not explicitly specified.

JavaScript

237

101 commits

updated Apr 30, 2026

See the code

README

prop-types-exact Version Badge

github actions coverage License Downloads

npm badge

For use with React PropTypes. Will error on any prop not explicitly specified.

Usage

import PropTypes from 'prop-types';
import exact from 'prop-types-exact';

function Foo({ foo, bar }) {
  return <div>{foo}{bar}</div>
}
Foo.propTypes = exact({
  foo: PropTypes.string,
  bar: PropTypes.number,
});

<Foo foo="hi" bar={3} /> // no warnings

<Foo foo="hi" bar={3} baz="extra" /> // propTypes warning!

Tests

Simply clone the repo, npm install, and run npm test

Contributors

ljharb

100 commits

jackwilsdon

1 commits

Languages

JavaScript

100.0%