alias: { type: Array, required: true },
method: { type: Function, required: true },
union: { type: [String, Number], required: true },
- literalUnion: { type: [String, String], required: true },
+ literalUnion: { type: String, required: true },
+ literalUnionNumber: { type: Number, required: true },
literalUnionMixed: { type: [String, Number, Boolean], required: true },
intersection: { type: Object, required: true },
foo: { type: [Function, null], required: true }
union: string | number
literalUnion: 'foo' | 'bar'
+ literalUnionNumber: 1 | 2 | 3 | 4 | 5
literalUnionMixed: 'foo' | 1 | boolean
intersection: Test & {}
foo: ((item: any) => boolean) | null
union: string | number
literalUnion: 'foo' | 'bar'
+ literalUnionNumber: 1 | 2 | 3 | 4 | 5
literalUnionMixed: 'foo' | 1 | boolean
intersection: Test & {}
foo: ((item: any) => boolean) | null
expect(content).toMatch(
`union: { type: [String, Number], required: true }`
)
+ expect(content).toMatch(`literalUnion: { type: String, required: true }`)
expect(content).toMatch(
- `literalUnion: { type: [String, String], required: true }`
+ `literalUnionNumber: { type: Number, required: true }`
)
expect(content).toMatch(
`literalUnionMixed: { type: [String, Number, Boolean], required: true }`
method: BindingTypes.PROPS,
union: BindingTypes.PROPS,
literalUnion: BindingTypes.PROPS,
+ literalUnionNumber: BindingTypes.PROPS,
literalUnionMixed: BindingTypes.PROPS,
intersection: BindingTypes.PROPS,
foo: BindingTypes.PROPS
return [
...new Set(
[].concat(
- node.types.map(t => inferRuntimeType(t, declaredTypes)) as any
+ ...(node.types.map(t => inferRuntimeType(t, declaredTypes)) as any)
)
)
]
}
function toRuntimeTypeString(types: string[]) {
- return types.some(t => t === 'null')
- ? `null`
- : types.length > 1
- ? `[${types.join(', ')}]`
- : types[0]
+ return types.length > 1 ? `[${types.join(', ')}]` : types[0]
}
function extractRuntimeEmits(