This repository has been archived by the owner on Feb 16, 2021. It is now read-only.
Support new flowtype syntax for exact object types #121
Comments
Is this new syntax already supported by babel? In the meanwhile support for the |
Probably soon will support: babel/babel#3702 |
gcanti
added a commit
that referenced
this issue
Sep 25, 2016
Support for |
@Riim added support for exact object syntax https://github.com/gcanti/babel-plugin-tcomb/releases/tag/v0.3.15 |
Thanks! With syntax is now all is well. Now would be appropriate test for it. https://yadi.sk/i/jZFp95HbvvtDs The generated tests have not changed: 'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = convertLocationData;
var _tcomb = __webpack_require__(1);
var _tcomb2 = _interopRequireDefault(_tcomb);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// @flow
function convertLocationData(locationData /*: {|
k: string,
v: string
|}*/) {
_assert(locationData, _tcomb2.default.interface({
k: _tcomb2.default.String,
v: _tcomb2.default.String
}), 'locationData');
return {
id: locationData.v,
name: locationData.k
};
}
console.log(convertLocationData({ k: '1', v: '2', qqq: '3' }));
function _assert(x, type, name) {
function message() {
return 'Invalid value ' + _tcomb2.default.stringify(x) + ' supplied to ' + name + ' (expected a ' + _tcomb2.default.getTypeName(type) + ')';
}
if (_tcomb2.default.isType(type)) {
if (!type.is(x)) {
type(x, [name + ': ' + _tcomb2.default.getTypeName(type)]);
_tcomb2.default.fail(message());
}
return type(x);
}
if (!(x instanceof type)) {
_tcomb2.default.fail(message());
}
return x;
}
|
Ouch! Thanks for the report |
Sorry for the inconvenience, should be fixed in the new release |
Many thanks. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
flow v0.32.0:
The text was updated successfully, but these errors were encountered: