File tree 2 files changed +97
-0
lines changed
packages/compiler-sfc/__tests__/compileScript
2 files changed +97
-0
lines changed Original file line number Diff line number Diff line change @@ -233,6 +233,33 @@ export default /*@__PURE__*/_defineComponent({
233
233
234
234
235
235
236
+ return { }
237
+ }
238
+
239
+ })"
240
+ ` ;
241
+
242
+ exports [` defineProps > w/ extends intersection type 1` ] = `
243
+ "import { defineComponent as _defineComponent } from 'vue'
244
+ type Foo = {
245
+ x ?: number ;
246
+ } ;
247
+ interface Props extends Foo {
248
+ z : number
249
+ y : string
250
+ }
251
+
252
+ export default /*#__PURE__*/_defineComponent({
253
+ props : {
254
+ z: { type: Number , required: true },
255
+ y: { type: String , required: true },
256
+ x: { type: Number , required: false }
257
+ },
258
+ setup (__props : any , { expose: __expose }) {
259
+ __expose();
260
+
261
+
262
+
236
263
return { }
237
264
}
238
265
@@ -268,6 +295,31 @@ export default /*@__PURE__*/_defineComponent({
268
295
269
296
270
297
298
+ return { }
299
+ }
300
+
301
+ })"
302
+ ` ;
303
+
304
+ exports [` defineProps > w/ intersection type 1` ] = `
305
+ "import { defineComponent as _defineComponent } from 'vue'
306
+ type Foo = {
307
+ x ?: number ;
308
+ } ;
309
+ type Bar = {
310
+ y : string ;
311
+ } ;
312
+
313
+ export default /*#__PURE__*/_defineComponent({
314
+ props : {
315
+ x: { type: Number , required: false },
316
+ y: { type: String , required: true }
317
+ },
318
+ setup (__props : any , { expose: __expose }) {
319
+ __expose();
320
+
321
+
322
+
271
323
return { }
272
324
}
273
325
Original file line number Diff line number Diff line change @@ -261,6 +261,51 @@ const props = defineProps({ foo: String })
261
261
} )
262
262
} )
263
263
264
+ test ( 'w/ extends intersection type' , ( ) => {
265
+ const { content, bindings } = compile ( `
266
+ <script setup lang="ts">
267
+ type Foo = {
268
+ x?: number;
269
+ };
270
+ interface Props extends Foo {
271
+ z: number
272
+ y: string
273
+ }
274
+ defineProps<Props>()
275
+ </script>
276
+ ` )
277
+ assertCode ( content )
278
+ expect ( content ) . toMatch ( `z: { type: Number, required: true }` )
279
+ expect ( content ) . toMatch ( `y: { type: String, required: true }` )
280
+ expect ( content ) . toMatch ( `x: { type: Number, required: false }` )
281
+ expect ( bindings ) . toStrictEqual ( {
282
+ x : BindingTypes . PROPS ,
283
+ y : BindingTypes . PROPS ,
284
+ z : BindingTypes . PROPS ,
285
+ } )
286
+ } )
287
+
288
+ test ( 'w/ intersection type' , ( ) => {
289
+ const { content, bindings } = compile ( `
290
+ <script setup lang="ts">
291
+ type Foo = {
292
+ x?: number;
293
+ };
294
+ type Bar = {
295
+ y: string;
296
+ };
297
+ defineProps<Foo & Bar>()
298
+ </script>
299
+ ` )
300
+ assertCode ( content )
301
+ expect ( content ) . toMatch ( `y: { type: String, required: true }` )
302
+ expect ( content ) . toMatch ( `x: { type: Number, required: false }` )
303
+ expect ( bindings ) . toStrictEqual ( {
304
+ x : BindingTypes . PROPS ,
305
+ y : BindingTypes . PROPS ,
306
+ } )
307
+ } )
308
+
264
309
test ( 'w/ exported interface' , ( ) => {
265
310
const { content, bindings } = compile ( `
266
311
<script setup lang="ts">
You can’t perform that action at this time.
0 commit comments