Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 16, 2021. It is now read-only.
This repository was archived by the owner on Feb 16, 2021. It is now read-only.

strict Struct with additional methods throws a TypeError on updating #267

@jfgodoy

Description

@jfgodoy

Test case:

const t = require('tcomb');

const Rectangle = t.struct({
  width: t.Number,
  height: t.Number
}, {strict: true});

Rectangle.prototype.getArea = function () {
  return this.width * this.height;
};

let r = Rectangle({width: 10, height: 10});
Rectangle.update(r, {width: {$set: 20}});

throws:

TypeError: [tcomb] Invalid additional prop "getArea" supplied to Struct{width: Number, height: Number}

replacing lib/assign.js with Object.assign seems to fix the problem.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions