@@ -288,6 +288,104 @@ tester.run('define-props-declaration', rule, {
288288 line : 3
289289 }
290290 ]
291+ } ,
292+ // Native Type with PropType
293+ {
294+ filename : 'test.vue' ,
295+ code : `
296+ <script setup lang="ts">
297+ const props = defineProps({
298+ kind: {
299+ type: String as PropType<'a' | 'b'>,
300+ }
301+ })
302+ </script>
303+ ` ,
304+ output : `
305+ <script setup lang="ts">
306+ const props = defineProps<{ kind: 'a' | 'b' }>()
307+ </script>
308+ ` ,
309+ errors : [
310+ {
311+ message : 'Use type-based declaration instead of runtime declaration.' ,
312+ line : 3
313+ }
314+ ]
315+ } ,
316+ // Object with PropType
317+ {
318+ filename : 'test.vue' ,
319+ code : `
320+ <script setup lang="ts">
321+ const props = defineProps({
322+ kind: {
323+ type: Object as PropType<{ id: number; name: string }>,
324+ }
325+ })
326+ </script>
327+ ` ,
328+ output : `
329+ <script setup lang="ts">
330+ const props = defineProps<{ kind: { id: number; name: string } }>()
331+ </script>
332+ ` ,
333+ errors : [
334+ {
335+ message : 'Use type-based declaration instead of runtime declaration.' ,
336+ line : 3
337+ }
338+ ]
339+ } ,
340+ // Array with PropType
341+ {
342+ filename : 'test.vue' ,
343+ code : `
344+ <script setup lang="ts">
345+ const props = defineProps({
346+ kind: {
347+ type: Array as PropType<string[]>,
348+ default: () => []
349+ }
350+ })
351+ </script>
352+ ` ,
353+ output : `
354+ <script setup lang="ts">
355+ const props = defineProps<{ kind: string[] }>()
356+ </script>
357+ ` ,
358+ errors : [
359+ {
360+ message : 'Use type-based declaration instead of runtime declaration.' ,
361+ line : 3
362+ }
363+ ]
364+ } ,
365+ // Function with PropType
366+ {
367+ filename : 'test.vue' ,
368+ code : `
369+ <script setup lang="ts">
370+ const props = defineProps({
371+ kind: {
372+ type: Function as PropType<(a: number, b: string) => boolean>,
373+ required: true
374+ }
375+ })
376+ </script>
377+ ` ,
378+ output : `
379+ <script setup lang="ts">
380+ const props = defineProps<{ kind: (a: number, b: string) => boolean }>()
381+ </script>
382+ ` ,
383+ errors : [
384+ {
385+ message : 'Use type-based declaration instead of runtime declaration.' ,
386+ line : 3
387+ }
388+ ]
291389 }
292390 ]
293391} )
0 commit comments