@@ -9,9 +9,12 @@ import {
9
9
VNode ,
10
10
Ref ,
11
11
defineModel ,
12
- toRefs
12
+ toRefs ,
13
+ ExtractPropTypes ,
14
+ ExtractPublicPropTypes ,
15
+ ExtractDefaultPropTypes
13
16
} from 'vue'
14
- import { describe , expectType } from './utils'
17
+ import { Prettify , describe , expectType } from './utils'
15
18
import { defineComponent } from 'vue'
16
19
import { useModel } from 'vue'
17
20
@@ -164,7 +167,7 @@ describe('withDefaults w/ boolean type', () => {
164
167
165
168
describe ( 'defineProps w/ runtime declaration' , ( ) => {
166
169
// runtime declaration
167
- const props = defineProps ( {
170
+ const propOptions = {
168
171
foo : String ,
169
172
bar : {
170
173
type : Number ,
@@ -174,12 +177,24 @@ describe('defineProps w/ runtime declaration', () => {
174
177
type : Array ,
175
178
required : true
176
179
}
177
- } )
180
+ } as const
181
+ const props = defineProps ( propOptions )
178
182
expectType < {
179
- foo ? : string
183
+ foo : string | undefined
180
184
bar : number
181
185
baz : unknown [ ]
182
186
} > ( props )
187
+ expectType < {
188
+ foo : string | undefined
189
+ bar : number
190
+ baz : unknown [ ]
191
+ } > ( { } as Prettify < ExtractPropTypes < typeof propOptions > > )
192
+ expectType < {
193
+ foo ?: string | undefined
194
+ bar ?: number | undefined
195
+ baz : unknown [ ]
196
+ } > ( { } as Prettify < ExtractPublicPropTypes < typeof propOptions > > )
197
+ expectType < { bar : number } > ( { } as ExtractDefaultPropTypes < typeof propOptions > )
183
198
184
199
props . foo && props . foo + 'bar'
185
200
props . bar + 1
@@ -191,6 +206,8 @@ describe('defineProps w/ runtime declaration', () => {
191
206
props2 . foo + props2 . bar
192
207
// @ts -expect-error
193
208
props2 . baz
209
+
210
+ expectType < Ref < string | undefined > > ( toRefs ( props ) . foo )
194
211
} )
195
212
196
213
describe ( 'defineEmits w/ type declaration' , ( ) => {
0 commit comments