flow2schema/tests/unions.js

52 lines
905 B
JavaScript
Raw Normal View History

2017-10-29 16:00:09 +03:00
type Type = {
a: string | number,
b: ?string,
};
interface Interface {
a: string | number;
b: ?string;
}
class Class {
a: string | number;
b: ?string;
}
// ###
({
Type: {
type: 'record',
name: 'Type',
fields: [{
name: 'a',
type: ['string', 'double'],
}, {
name: 'b',
type: ['null', 'string'],
}],
},
Interface: {
type: 'record',
name: 'Interface',
fields: [{
name: 'a',
type: ['string', 'double'],
}, {
name: 'b',
type: ['null', 'string'],
}],
},
Class: {
type: 'record',
name: 'Class',
fields: [{
name: 'a',
type: ['string', 'double'],
}, {
name: 'b',
type: ['null', 'string'],
}],
},
});