@@ -22,6 +22,7 @@ describe('with object props', () => {
22
22
a ?: number | undefined
23
23
aa : number
24
24
aaa : number | null
25
+ aaaa : number | undefined
25
26
b : string
26
27
e ?: Function
27
28
h : boolean
@@ -63,6 +64,11 @@ describe('with object props', () => {
63
64
type : Number as PropType < number | null > ,
64
65
default : 1 ,
65
66
} ,
67
+ aaaa : {
68
+ type : Number as PropType < number | undefined > ,
69
+ // `as const` prevents widening to `boolean` (keeps literal `true` type)
70
+ required : true as const ,
71
+ } ,
66
72
// required should make property non-void
67
73
b : {
68
74
type : String ,
@@ -158,6 +164,11 @@ describe('with object props', () => {
158
164
expectType < ExpectedProps [ 'a' ] > ( props . a )
159
165
expectType < ExpectedProps [ 'aa' ] > ( props . aa )
160
166
expectType < ExpectedProps [ 'aaa' ] > ( props . aaa )
167
+
168
+ // @ts -expect-error should included `undefined`
169
+ expectType < number > ( props . aaaa )
170
+ expectType < ExpectedProps [ 'aaaa' ] > ( props . aaaa )
171
+
161
172
expectType < ExpectedProps [ 'b' ] > ( props . b )
162
173
expectType < ExpectedProps [ 'e' ] > ( props . e )
163
174
expectType < ExpectedProps [ 'h' ] > ( props . h )
@@ -285,6 +296,7 @@ describe('with object props', () => {
285
296
expectType < JSX . Element > (
286
297
< MyComponent
287
298
a = { 1 }
299
+ aaaa = { 1 }
288
300
b = "b"
289
301
bb = "bb"
290
302
e = { ( ) => { } }
@@ -311,6 +323,7 @@ describe('with object props', () => {
311
323
312
324
expectType < Component > (
313
325
< MyComponent
326
+ aaaa = { 1 }
314
327
b = "b"
315
328
dd = { { n : 1 } }
316
329
ddd = { [ 'ddd' ] }
0 commit comments