-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.ts
62 lines (56 loc) · 1.2 KB
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import Vue from 'vue';
import type { TypedVueExtendOverride } from './index';
const Component = Vue.extend({
methods: {
a() {
return 'a';
},
async b() {
return 'b';
},
},
});
const DefaultVueExtendSpec = () => {
// Expect default VueComponent.extend doesn't detect type error
Component.extend({
methods: {
async b() {
return 5;
},
},
});
};
export const TypedVueExtendOverrideSpec = () => {
// Expected usage
Component.extend({
methods: {
async b() {
return 'bb';
},
},
} as TypedVueExtendOverride<typeof Component>);
// @ts-expect-error Detects method type mismatch (string)
Component.extend({
methods: {
async b() {
return 6;
},
},
} as TypedVueExtendOverride<typeof Component>);
// @ts-expect-error Detects method type mismatch (async)
Component.extend({
methods: {
b() {
return 'bb';
},
},
} as TypedVueExtendOverride<typeof Component>);
// @ts-expect-error Detects method typo / doesn't allow new methods
Component.extend({
methods: {
async bbb() {
return 'bb';
},
},
} as TypedVueExtendOverride<typeof Component>);
};