mirror of https://github.com/vuejs/core.git
fix(compiler-sfc): infer TSIntersectionType in defineProps (#7394)
This commit is contained in:
parent
1b69d5f2f4
commit
151a8ad6b9
|
|
@ -1643,6 +1643,7 @@ export default /*#__PURE__*/_defineComponent({
|
|||
literalUnionNumber: { type: Number, required: true },
|
||||
literalUnionMixed: { type: [String, Number, Boolean], required: true },
|
||||
intersection: { type: Object, required: true },
|
||||
intersection2: { type: String, required: true },
|
||||
foo: { type: [Function, null], required: true }
|
||||
},
|
||||
setup(__props: any, { expose }) {
|
||||
|
|
|
|||
|
|
@ -972,6 +972,7 @@ const emit = defineEmits(['a', 'b'])
|
|||
literalUnionNumber: 1 | 2 | 3 | 4 | 5
|
||||
literalUnionMixed: 'foo' | 1 | boolean
|
||||
intersection: Test & {}
|
||||
intersection2: 'foo' & ('foo' | 'bar')
|
||||
foo: ((item: any) => boolean) | null
|
||||
}>()
|
||||
</script>`)
|
||||
|
|
@ -1014,6 +1015,7 @@ const emit = defineEmits(['a', 'b'])
|
|||
`literalUnionMixed: { type: [String, Number, Boolean], required: true }`
|
||||
)
|
||||
expect(content).toMatch(`intersection: { type: Object, required: true }`)
|
||||
expect(content).toMatch(`intersection2: { type: String, required: true }`)
|
||||
expect(content).toMatch(`foo: { type: [Function, null], required: true }`)
|
||||
expect(bindings).toStrictEqual({
|
||||
string: BindingTypes.PROPS,
|
||||
|
|
@ -1044,6 +1046,7 @@ const emit = defineEmits(['a', 'b'])
|
|||
literalUnionNumber: BindingTypes.PROPS,
|
||||
literalUnionMixed: BindingTypes.PROPS,
|
||||
intersection: BindingTypes.PROPS,
|
||||
intersection2: BindingTypes.PROPS,
|
||||
foo: BindingTypes.PROPS
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -2088,6 +2088,7 @@ function inferRuntimeType(
|
|||
case 'TSParenthesizedType':
|
||||
return inferRuntimeType(node.typeAnnotation, declaredTypes)
|
||||
case 'TSUnionType':
|
||||
case 'TSIntersectionType':
|
||||
return [
|
||||
...new Set(
|
||||
[].concat(
|
||||
|
|
@ -2095,8 +2096,6 @@ function inferRuntimeType(
|
|||
)
|
||||
)
|
||||
]
|
||||
case 'TSIntersectionType':
|
||||
return ['Object']
|
||||
|
||||
case 'TSSymbolKeyword':
|
||||
return ['Symbol']
|
||||
|
|
|
|||
Loading…
Reference in New Issue