Skip to content

Commit e17f431

Browse files
committed
prevent Data to be unkown
1 parent f7761fc commit e17f431

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/mount.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ import { stubComponents } from './stubs'
3434

3535
type Slot = VNode | string | { render: Function }
3636

37-
interface MountingOptions<Props, Data = {}> {
38-
data?: () => Data
37+
interface MountingOptions<Props, Data extends object = {}> {
38+
data?: () => Data extends unknown ? never : Data
3939
props?: Props
4040
attrs?: Record<string, unknown>
4141
slots?: {

test-dts/mount.d-test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ expectType<string>(
2020
}).vm.a
2121
)
2222

23+
// no data provided
24+
expectError(
25+
mount(AppWithDefine, {
26+
data() {
27+
return {
28+
myVal: 1
29+
}
30+
}
31+
})
32+
)
33+
2334
// can receive extra props
2435
// ideally, it should not
2536
// but the props have type { a: string } & VNodeProps

0 commit comments

Comments
 (0)