Support for Array<T> and $ReadOnlyArray<T>
parent
9941cbf380
commit
d24a640ad5
|
@ -1,8 +1,29 @@
|
|||
import {invariant} from './utils';
|
||||
import type {Type} from './types';
|
||||
|
||||
export default {
|
||||
Buffer() {
|
||||
return {
|
||||
kind: 'reference',
|
||||
to: ["Buffer"],
|
||||
to: ['Buffer'],
|
||||
};
|
||||
},
|
||||
Array(params: (?Type)[]): ?Type {
|
||||
invariant(params.length === 1);
|
||||
invariant(params[0]);
|
||||
|
||||
return {
|
||||
kind: 'array',
|
||||
items: params[0],
|
||||
};
|
||||
},
|
||||
$ReadOnlyArray(params: (?Type)[]): ?Type {
|
||||
invariant(params.length === 1);
|
||||
invariant(params[0]);
|
||||
|
||||
return {
|
||||
kind: 'array',
|
||||
items: params[0],
|
||||
};
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,13 +1,19 @@
|
|||
type Type = {
|
||||
a: string[],
|
||||
b: Array<string>,
|
||||
c: $ReadOnlyArray<string>,
|
||||
};
|
||||
|
||||
interface Interface {
|
||||
a: string[];
|
||||
b: Array<string>;
|
||||
c: $ReadOnlyArray<string>;
|
||||
}
|
||||
|
||||
class Class {
|
||||
a: string[];
|
||||
b: Array<string>;
|
||||
c: $ReadOnlyArray<string>;
|
||||
}
|
||||
|
||||
export {Type, Interface, Class};
|
||||
|
|
|
@ -3,29 +3,65 @@
|
|||
{
|
||||
"id": ["arrays", "Type"],
|
||||
"kind": "record",
|
||||
"fields": [{
|
||||
"name": "a",
|
||||
"value": {"kind": "array", "items": {"kind": "string"}},
|
||||
"required": true
|
||||
}]
|
||||
"fields": [
|
||||
{
|
||||
"name": "a",
|
||||
"value": {"kind": "array", "items": {"kind": "string"}},
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "b",
|
||||
"value": {"kind": "array", "items": {"kind": "string"}},
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "c",
|
||||
"value": {"kind": "array", "items": {"kind": "string"}},
|
||||
"required": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": ["arrays", "Interface"],
|
||||
"kind": "record",
|
||||
"fields": [{
|
||||
"name": "a",
|
||||
"value": {"kind": "array", "items": {"kind": "string"}},
|
||||
"required": true
|
||||
}]
|
||||
"fields": [
|
||||
{
|
||||
"name": "a",
|
||||
"value": {"kind": "array", "items": {"kind": "string"}},
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "b",
|
||||
"value": {"kind": "array", "items": {"kind": "string"}},
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "c",
|
||||
"value": {"kind": "array", "items": {"kind": "string"}},
|
||||
"required": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": ["arrays", "Class"],
|
||||
"kind": "record",
|
||||
"fields": [{
|
||||
"name": "a",
|
||||
"value": {"kind": "array", "items": {"kind": "string"}},
|
||||
"required": true
|
||||
}]
|
||||
"fields": [
|
||||
{
|
||||
"name": "a",
|
||||
"value": {"kind": "array", "items": {"kind": "string"}},
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "b",
|
||||
"value": {"kind": "array", "items": {"kind": "string"}},
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "c",
|
||||
"value": {"kind": "array", "items": {"kind": "string"}},
|
||||
"required": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue