tcomb icon indicating copy to clipboard operation
tcomb copied to clipboard

defaultProps support for t.interface

Open hexpunk opened this issue 9 years ago • 1 comments

Version

3.2.20

Expected behaviour

t.interface to support defaultProps like t.struct does.

Actual behaviour

t.interface does not support defaultProps.

Steps to reproduce

const Wearable = t.interface({
  wearable: t.Boolean
}, {
  name: 'Wearable',
  defaultProps: {
    wearable: true
  }
});

const wearable = new Wearable({});

Stack trace and console log

Uncaught TypeError: [tcomb] Invalid value undefined supplied to Wearable/wearable: Boolean

hexpunk avatar Apr 14 '17 01:04 hexpunk

defaultProps support for structs was added in this commit.

Download avatar Apr 15 '17 12:04 Download