Skip to content

Commit 390bda3

Browse files
committed
test(types): add failing test
1 parent c86e7ad commit 390bda3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test-dts/defineComponent.test-d.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ describe('with object props', () => {
2727
ddd: string[]
2828
eee: () => { a: string }
2929
fff: (a: number, b: string) => { a: boolean }
30+
fnWithDefault: (a: number) => number
31+
fnWithoutDefault?: (a: number) => number
3032
hhh: boolean
3133
ggg: 'foo' | 'bar'
3234
validated?: string
@@ -80,6 +82,15 @@ describe('with object props', () => {
8082
type: Function as PropType<(a: number, b: string) => { a: boolean }>,
8183
required: true
8284
},
85+
// with default
86+
fnWithDefault: {
87+
type: Function as PropType<(a: number) => number>,
88+
default: (a: number) => a * 2
89+
},
90+
// without default
91+
fnWithoutDefault: {
92+
type: Function as PropType<(a: number) => number>
93+
},
8394
hhh: {
8495
type: Boolean,
8596
required: true
@@ -113,6 +124,8 @@ describe('with object props', () => {
113124
expectType<ExpectedProps['hhh']>(props.hhh)
114125
expectType<ExpectedProps['ggg']>(props.ggg)
115126
expectType<ExpectedProps['validated']>(props.validated)
127+
expectType<ExpectedProps['fnWithDefault']>(props.fnWithDefault)
128+
expectType<ExpectedProps['fnWithoutDefault']>(props.fnWithoutDefault)
116129

117130
// @ts-expect-error props should be readonly
118131
expectError((props.a = 1))

0 commit comments

Comments
 (0)