Add Object special

master
Paul Loyd 2017-11-28 20:39:56 +03:00
parent d24a640ad5
commit 418f997d31
3 changed files with 59 additions and 1 deletions

View File

@ -2,7 +2,18 @@ import {invariant} from './utils';
import type {Type} from './types';
export default {
Buffer() {
Object(params: (?Type)[]): ?Type {
invariant(params.length === 0);
return {
kind: 'map',
keys: {kind: 'mixed'},
values: {kind: 'mixed'},
};
},
Buffer(params: (?Type)[]): ?Type {
invariant(params.length === 0);
return {
kind: 'reference',
to: ['Buffer'],

11
tests/samples/objects.js Normal file
View File

@ -0,0 +1,11 @@
type X = Object;
interface Y {
y: Object;
}
class Z {
z: Object;
}
export {X, Y, Z};

View File

@ -0,0 +1,36 @@
{
"types": [
{
"id": ["objects", "X"],
"kind": "map",
"keys": {"kind": "mixed"},
"values": {"kind": "mixed"}
},
{
"id": ["objects", "Y"],
"kind": "record",
"fields": [{
"name": "y",
"value": {
"kind": "map",
"keys": {"kind": "mixed"},
"values": {"kind": "mixed"}
},
"required": true
}]
},
{
"id": ["objects", "Z"],
"kind": "record",
"fields": [{
"name": "z",
"value": {
"kind": "map",
"keys": {"kind": "mixed"},
"values": {"kind": "mixed"}
},
"required": true
}]
}
]
}