Skip to content

Commit e59981d

Browse files
cexbrayatpikax
andauthored
chore: bump to vue v3.2.34 (#1510)
* chore: bump to vue v3.2.34 * chore: fix tests * chore: clean tsd tests for vue v3.2.34 * chore: lint fix * chore: add overload on findComponent for component Options Co-authored-by: Carlos Rodrigues <[email protected]>
1 parent 6aaf559 commit e59981d

File tree

10 files changed

+140
-95
lines changed

10 files changed

+140
-95
lines changed

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
"@typescript-eslint/eslint-plugin": "^5.25.0",
3535
"@typescript-eslint/parser": "^5.25.0",
3636
"@vue/babel-plugin-jsx": "^1.1.1",
37-
"@vue/compat": "3.2.33",
38-
"@vue/compiler-dom": "3.2.33",
39-
"@vue/compiler-sfc": "3.2.33",
37+
"@vue/compat": "3.2.34",
38+
"@vue/compiler-dom": "3.2.34",
39+
"@vue/compiler-sfc": "3.2.34",
4040
"@vue/vue3-jest": "27.0.0-alpha.4",
4141
"babel-jest": "27.5.1",
4242
"babel-preset-jest": "28.0.2",
@@ -57,7 +57,7 @@
5757
"tslib": "2.4.0",
5858
"typescript": "4.6.4",
5959
"vitepress": "^0.22.4",
60-
"vue": "3.2.33",
60+
"vue": "3.2.34",
6161
"vue-class-component": "^8.0.0-rc.1",
6262
"vue-jest": "^5.0.0-alpha.10",
6363
"vue-router": "^4.0.15",

src/baseWrapper.ts

+27
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ import { textContent } from './utils'
22
import type { TriggerOptions } from './createDomEvent'
33
import {
44
ComponentInternalInstance,
5+
ComponentOptions,
56
ComponentPublicInstance,
7+
ComputedOptions,
8+
CreateComponentPublicInstance,
69
FunctionalComponent,
10+
MethodOptions,
711
nextTick
812
} from 'vue'
913
import { createDOMEvent } from './createDomEvent'
@@ -99,6 +103,29 @@ export default abstract class BaseWrapper<ElementType extends Node>
99103

100104
// searching by string without specifying component results in WrapperLike object
101105
findComponent<T extends never>(selector: string): WrapperLike
106+
// Find Component Options aka plain object
107+
findComponent<
108+
Props,
109+
RawBindings = any,
110+
D = any,
111+
C extends ComputedOptions = ComputedOptions,
112+
M extends MethodOptions = MethodOptions
113+
>(
114+
selector: ComponentOptions<Props, RawBindings, D, C, M>
115+
): VueWrapper<CreateComponentPublicInstance<Props, RawBindings, D, C, M>>
116+
findComponent<T extends ComponentOptions>(
117+
selector: string
118+
): VueWrapper<
119+
T extends ComponentOptions<
120+
infer Props,
121+
infer RawBindings,
122+
infer D,
123+
infer C,
124+
infer M
125+
>
126+
? CreateComponentPublicInstance<Props, RawBindings, D, C, M>
127+
: VueWrapper<CreateComponentPublicInstance>
128+
>
102129
// searching for component created via defineComponent results in VueWrapper of proper type
103130
findComponent<T extends DefinedComponent>(
104131
selector: T | Exclude<FindComponentSelector, FunctionalComponent>

src/mount.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
EmitsOptions,
2323
ComputedOptions,
2424
ComponentPropsOptions,
25+
ComponentProvideOptions,
2526
ComponentOptions,
2627
ConcreteComponent,
2728
Prop
@@ -131,6 +132,8 @@ export function mount<
131132
Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
132133
E extends EmitsOptions = Record<string, any>,
133134
EE extends string = string,
135+
Provide extends ComponentProvideOptions = ComponentProvideOptions,
136+
RawOptions extends {} = {},
134137
PP = PublicProps,
135138
Props = Readonly<ExtractPropTypes<PropsOrPropOptions>>,
136139
Defaults = ExtractDefaultPropTypes<PropsOrPropOptions>
@@ -145,6 +148,8 @@ export function mount<
145148
Extends,
146149
E,
147150
EE,
151+
Provide,
152+
RawOptions,
148153
PP,
149154
Props,
150155
Defaults
@@ -166,6 +171,8 @@ export function mount<
166171
Extends,
167172
E,
168173
EE,
174+
Provide,
175+
RawOptions,
169176
PP,
170177
Props,
171178
Defaults
@@ -275,7 +282,7 @@ export function mount(
275282
inputComponent: any,
276283
options?: MountingOptions<any> & Record<string, any>
277284
): VueWrapper<any> {
278-
// normalise the incoming component
285+
// normalize the incoming component
279286
const originalComponent = unwrapLegacyVueExtendComponent(inputComponent)
280287
let component: ConcreteComponent
281288
const instanceOptions = getInstanceOptions(options ?? {})

src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface NameSelector {
2121
export type FindAllComponentsSelector =
2222
| DefinedComponent
2323
| FunctionalComponent
24+
| ComponentOptions
2425
| NameSelector
2526
| string
2627
export type FindComponentSelector = RefSelector | FindAllComponentsSelector

test-dts/mount.d-test.ts

+18-13
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ mount(AppWithDefine, {
5656
})
5757

5858
expectError(
59-
// @ts-expect-error wrong prop type should not compile
6059
mount(AppWithDefine, {
60+
// @ts-expect-error wrong prop type should not compile
6161
props: { a: 2 }
6262
})
6363
)
@@ -186,14 +186,12 @@ declare const FunctionalComponentEmit: FunctionalComponent<
186186
level: number
187187
},
188188
{ hello: (foo: string, bar: string) => void }
189-
>
189+
>
190190

191191
mount(FunctionalComponent)
192192
mount(defineComponent(FunctionalComponent))
193193

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

199197
// class component
@@ -204,7 +202,7 @@ mount(defineComponent(FunctionalComponentEmit))
204202
}
205203
})
206204
class ClassComponent extends Vue {
207-
dataText: string = ''
205+
dataText = ''
208206
get computedMsg(): string {
209207
return `Message: ${(this.$props as any).msg}`
210208
}
@@ -224,6 +222,7 @@ class CustomClassComponent<Props extends {} = {}> {
224222
private static __vccValue?: ComponentOptions
225223
static get __vccOpts(): ComponentOptions {
226224
if (this.__vccValue) return this.__vccValue
225+
// eslint-disable-next-line @typescript-eslint/no-this-alias
227226
const CompConstructor = this
228227
return (this.__vccValue = {
229228
name: CompConstructor.name,
@@ -279,14 +278,20 @@ class WithPropCustomClassComponent extends CustomClassComponent<CustomClassCompo
279278
}
280279

281280
expectError(
282-
// @ts-expect-error should has props error
283-
mount<WithPropCustomClassComponent, CustomClassComponentProps>(WithPropCustomClassComponent, {
284-
props: {}
285-
})
281+
mount<WithPropCustomClassComponent, CustomClassComponentProps>(
282+
// @ts-expect-error should has props error
283+
WithPropCustomClassComponent,
284+
{
285+
props: {}
286+
}
287+
)
288+
)
289+
mount<WithPropCustomClassComponent, CustomClassComponentProps>(
290+
WithPropCustomClassComponent,
291+
{
292+
props: { size: 'small' }
293+
}
286294
)
287-
mount<WithPropCustomClassComponent, CustomClassComponentProps>(WithPropCustomClassComponent, {
288-
props: { size: 'small' }
289-
})
290295

291296
// endregion
292297

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

314319
expectError(
315320
mount(
316-
// @ts-expect-error
317321
defineComponent({
318322
props: {
319323
baz: String,
@@ -324,6 +328,7 @@ expectError(
324328
}
325329
}),
326330
{
331+
// @ts-expect-error
327332
props: {
328333
baz: 'hello'
329334
}

test-dts/shallowMount.d-test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ shallowMount(AppWithDefine, {
2727
})
2828

2929
expectError(
30-
// @ts-expect-error wrong prop type should not compile
3130
shallowMount(AppWithDefine, {
31+
// @ts-expect-error wrong prop type should not compile
3232
props: { a: 2 }
3333
})
3434
)
@@ -97,7 +97,7 @@ wrapper = shallowMount(AppWithoutProps, {
9797
}
9898
})
9999
class ClassComponent extends Vue {
100-
dataText: string = ''
100+
dataText = ''
101101
get computedMsg(): string {
102102
return `Message: ${(this.$props as any).msg}`
103103
}

tests/features/compat.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { mount } from '../../src'
33

44
jest.mock('vue', () => mockVue)
55

6-
const { configureCompat, extend, defineComponent, h } = mockVue as any
6+
const { configureCompat, extend, defineComponent, h } = mockVue
77

88
describe('@vue/compat build', () => {
99
describe.each(['suppress-warning', false])(

tests/mountingOptions/mocks.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ describe('mocks', () => {
3838
</div>
3939
`,
4040
computed: {
41-
url() {
41+
url(): string {
4242
return `/posts/${this.$route.params.id}`
4343
},
44-
id() {
44+
id(): string | string[] {
4545
return this.$route.params.id
4646
}
4747
},

types/compat.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
declare module '@vue/compat' {
22
export * from 'vue'
3+
export function extend<T>(options: T): T
4+
5+
export function configureCompat(
6+
option: Record<string, boolean | string | number>
7+
): void
38
}

0 commit comments

Comments
 (0)