Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for iface type #180

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

synaptiko
Copy link

Overview

Summary

Loosely based on #116
We use iface in our project, it's really similar to shape, the difference is that only specified props are checked.

Here's an example:

propTypes: {
  dog: PropTypes.iface({
    bark: PropTypes.function.isRequired,
    color: PropTypes.string
  }).isRequired
},

Then you can pass:

dog: Ember.Object.extend({
  bark() {
    console.log('woof woof')
  }
}).create()

or

dog: Ember.Object.extend({
  bark() {
    console.log('ruff ruff')
  },
  color: 'black',
  breed: 'affenpinscher'
}).create()

Both are accepted.

Checklist

If there will be interest in this PR, I can go over the list below and update documentation and provide some tests.

  • I have added tests that prove my fix is effective or that my feature works
  • I have evaluated if the README.md documentation needs to be updated
  • I have evaluated if the /tests/dummy/ app needs to be modified
  • I have evaluated if DocBlock headers needed to be added or updated
  • I have verified that lint and tests pass locally with my changes

Semver

This project uses semver, please check the scope of this PR:

  • #none#
  • #patch#
  • #minor#
  • #major#

CHANGELOG

Support for iface type which is checking provided props similar to shape type but the missing props are tolerated.

@synaptiko synaptiko requested review from a team as code owners December 3, 2018 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants