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

Commit

Permalink
declare: remove unnecessary limitation, fix #291
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Sep 1, 2017
1 parent 5bbaf1a commit 11388e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/declare.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = function declare(name) {
if (process.env.NODE_ENV !== 'production') {
assert(isType(spec), function () { return 'Invalid argument type ' + assert.stringify(spec) + ' supplied to define(type) (expected a type)'; });
assert(isNil(type), function () { return 'Declare.define(type) can only be invoked once'; });
assert(isNil(spec.meta.name) && Object.keys(spec.prototype).length === 0, function () { return 'Invalid argument type ' + assert.stringify(spec) + ' supplied to define(type) (expected a fresh, unnamed type)'; });
// assert(isNil(spec.meta.name) && Object.keys(spec.prototype).length === 0, function () { return 'Invalid argument type ' + assert.stringify(spec) + ' supplied to define(type) (expected a fresh, unnamed type)'; });
}

if (isUnion(spec) && Declare.hasOwnProperty('dispatch')) {
Expand Down
14 changes: 7 additions & 7 deletions test/declare.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ describe('t.declare([name])', function () {
assert.equal(42, Struct({value: 42}).getValue());
});

it('should throw when defined with a non-fresh type', function() {
throwsWithMessage(function () {
var ANum = t.declare();
ANum.define(t.Number);
}, '[tcomb] Invalid argument type "Number" supplied to define(type) (expected a fresh, unnamed type)');
});
// it('should throw when defined with a non-fresh type', function() {
// throwsWithMessage(function () {
// var ANum = t.declare();
// ANum.define(t.Number);
// }, '[tcomb] Invalid argument type "Number" supplied to define(type) (expected a fresh, unnamed type)');
// });

it('should play well with identity', function () {
var Tuple = t.declare('Tuple');
Expand Down Expand Up @@ -192,4 +192,4 @@ describe('t.declare([name])', function () {

});

});
});

0 comments on commit 11388e7

Please sign in to comment.