Skip to content

Commit

Permalink
chore: clean tsd tests for vue v3.2.34
Browse files Browse the repository at this point in the history
  • Loading branch information
cexbrayat committed May 19, 2022
1 parent 9a48c64 commit 882450e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
31 changes: 18 additions & 13 deletions test-dts/mount.d-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ mount(AppWithDefine, {
})

expectError(
// @ts-expect-error wrong prop type should not compile
mount(AppWithDefine, {
// @ts-expect-error wrong prop type should not compile
props: { a: 2 }
})
)
Expand Down Expand Up @@ -186,14 +186,12 @@ declare const FunctionalComponentEmit: FunctionalComponent<
level: number
},
{ hello: (foo: string, bar: string) => void }
>
>

mount(FunctionalComponent)
mount(defineComponent(FunctionalComponent))

mount(FunctionalComponentEmit)

// @ts-ignore vue 3.0.2 doesn't work. FIX: https://github.com/vuejs/vue-next/pull/2494
mount(defineComponent(FunctionalComponentEmit))

// class component
Expand All @@ -204,7 +202,7 @@ mount(defineComponent(FunctionalComponentEmit))
}
})
class ClassComponent extends Vue {
dataText: string = ''
dataText = ''
get computedMsg(): string {
return `Message: ${(this.$props as any).msg}`
}
Expand All @@ -224,6 +222,7 @@ class CustomClassComponent<Props extends {} = {}> {
private static __vccValue?: ComponentOptions
static get __vccOpts(): ComponentOptions {
if (this.__vccValue) return this.__vccValue
// eslint-disable-next-line @typescript-eslint/no-this-alias
const CompConstructor = this
return (this.__vccValue = {
name: CompConstructor.name,
Expand Down Expand Up @@ -279,14 +278,20 @@ class WithPropCustomClassComponent extends CustomClassComponent<CustomClassCompo
}

expectError(
// @ts-expect-error should has props error
mount<WithPropCustomClassComponent, CustomClassComponentProps>(WithPropCustomClassComponent, {
props: {}
})
mount<WithPropCustomClassComponent, CustomClassComponentProps>(
// @ts-expect-error should has props error
WithPropCustomClassComponent,
{
props: {}
}
)
)
mount<WithPropCustomClassComponent, CustomClassComponentProps>(
WithPropCustomClassComponent,
{
props: { size: 'small' }
}
)
mount<WithPropCustomClassComponent, CustomClassComponentProps>(WithPropCustomClassComponent, {
props: { size: 'small' }
})

// endregion

Expand All @@ -313,7 +318,6 @@ mount(Foo, {

expectError(
mount(
// @ts-expect-error
defineComponent({
props: {
baz: String,
Expand All @@ -324,6 +328,7 @@ expectError(
}
}),
{
// @ts-expect-error
props: {
baz: 'hello'
}
Expand Down
4 changes: 2 additions & 2 deletions test-dts/shallowMount.d-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ shallowMount(AppWithDefine, {
})

expectError(
// @ts-expect-error wrong prop type should not compile
shallowMount(AppWithDefine, {
// @ts-expect-error wrong prop type should not compile
props: { a: 2 }
})
)
Expand Down Expand Up @@ -97,7 +97,7 @@ wrapper = shallowMount(AppWithoutProps, {
}
})
class ClassComponent extends Vue {
dataText: string = ''
dataText = ''
get computedMsg(): string {
return `Message: ${(this.$props as any).msg}`
}
Expand Down

0 comments on commit 882450e

Please sign in to comment.