Add tests for unions

master
Paul Loyd 2017-10-29 16:00:09 +03:00
parent d8eb1bd3e8
commit d9aef3b22e
1 changed files with 51 additions and 0 deletions

51
tests/unions.js Normal file
View File

@ -0,0 +1,51 @@
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'],
}],
},
});