Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,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 }) {
Expand Down
3 changes: 3 additions & 0 deletions packages/compiler-sfc/__tests__/compileScript.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,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>`)
Expand Down Expand Up @@ -1008,6 +1009,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,
Expand Down Expand Up @@ -1036,6 +1038,7 @@ const emit = defineEmits(['a', 'b'])
literalUnionNumber: BindingTypes.PROPS,
literalUnionMixed: BindingTypes.PROPS,
intersection: BindingTypes.PROPS,
intersection2: BindingTypes.PROPS,
foo: BindingTypes.PROPS
})
})
Expand Down
3 changes: 1 addition & 2 deletions packages/compiler-sfc/src/compileScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2069,15 +2069,14 @@ function inferRuntimeType(
case 'TSParenthesizedType':
return inferRuntimeType(node.typeAnnotation, declaredTypes)
case 'TSUnionType':
case 'TSIntersectionType':
return [
...new Set(
[].concat(
...(node.types.map(t => inferRuntimeType(t, declaredTypes)) as any)
)
)
]
case 'TSIntersectionType':
return ['Object']

case 'TSSymbolKeyword':
return ['Symbol']
Expand Down