|
|
@@ -261,6 +261,51 @@ const props = defineProps({ foo: String })
|
|
|
})
|
|
|
})
|
|
|
|
|
|
+ test('w/ extends intersection type', () => {
|
|
|
+ const { content, bindings } = compile(`
|
|
|
+ <script setup lang="ts">
|
|
|
+ type Foo = {
|
|
|
+ x?: number;
|
|
|
+ };
|
|
|
+ interface Props extends Foo {
|
|
|
+ z: number
|
|
|
+ y: string
|
|
|
+ }
|
|
|
+ defineProps<Props>()
|
|
|
+ </script>
|
|
|
+ `)
|
|
|
+ assertCode(content)
|
|
|
+ expect(content).toMatch(`z: { type: Number, required: true }`)
|
|
|
+ expect(content).toMatch(`y: { type: String, required: true }`)
|
|
|
+ expect(content).toMatch(`x: { type: Number, required: false }`)
|
|
|
+ expect(bindings).toStrictEqual({
|
|
|
+ x: BindingTypes.PROPS,
|
|
|
+ y: BindingTypes.PROPS,
|
|
|
+ z: BindingTypes.PROPS,
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ test('w/ intersection type', () => {
|
|
|
+ const { content, bindings } = compile(`
|
|
|
+ <script setup lang="ts">
|
|
|
+ type Foo = {
|
|
|
+ x?: number;
|
|
|
+ };
|
|
|
+ type Bar = {
|
|
|
+ y: string;
|
|
|
+ };
|
|
|
+ defineProps<Foo & Bar>()
|
|
|
+ </script>
|
|
|
+ `)
|
|
|
+ assertCode(content)
|
|
|
+ expect(content).toMatch(`y: { type: String, required: true }`)
|
|
|
+ expect(content).toMatch(`x: { type: Number, required: false }`)
|
|
|
+ expect(bindings).toStrictEqual({
|
|
|
+ x: BindingTypes.PROPS,
|
|
|
+ y: BindingTypes.PROPS,
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
test('w/ exported interface', () => {
|
|
|
const { content, bindings } = compile(`
|
|
|
<script setup lang="ts">
|