|
1 | 1 | <script setup lang="ts">
|
2 |
| -import { watchEffect, ref } from "vue"; // watchEffect: (effect: WatchEffect, options?: WatchOptionsBase | undefined) => WatchStopHandle, watchEffect: (effect: WatchEffect, options?: WatchOptionsBase | undefined) => WatchStopHandle, ref: { <T>(value: T): Ref<UnwrapRef<T>>; <T = any>(): Ref<T | undefined>; }, ref: { <T>(value: T): Ref<UnwrapRef<T>>; <T = any>(): Ref<T | undefined>; } |
3 |
| -import Foo from "./component.vue"; // Foo: DefineComponent<{}, { exposeA: Ref<number>; exposeFn: () => Ret | null; exposeFn2: () => number; }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ... 5 more ..., {}> |
4 |
| -type VMFoo = InstanceType<typeof Foo>; // VMFoo: CreateComponentPublicInstance<Readonly<ExtractPropTypes<{}>>, { exposeA: Ref<number>; exposeFn: () => Ret | null; exposeFn2: () => number; }, {}, {}, {}, ComponentOptionsMixin, ... 13 more ..., {}>, InstanceType: InstanceType<T>, Foo: DefineComponent<{}, { exposeA: Ref<number>; exposeFn: () => Ret | null; exposeFn2: () => number; }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ... 5 more ..., {}> |
5 |
| -let a = ref<VMFoo | null>(null); // a: Ref<CreateComponentPublicInstance<Readonly<ExtractPropTypes<{}>>, { exposeA: Ref<number>; exposeFn: () => Ret | null; exposeFn2: () => number; }, {}, {}, {}, ComponentOptionsMixin, ... 13 more ..., {}> | null>, ref<VMFoo | null>(null): Ref<CreateComponentPublicInstance<Readonly<ExtractPropTypes<{}>>, { exposeA: Ref<number>; exposeFn: () => Ret | null; exposeFn2: () => number; }, {}, {}, {}, ComponentOptionsMixin, ... 13 more ..., {}> | null> |
6 |
| -watchEffect(() => { // watchEffect(() => { if (a.value) fn(a); }): WatchStopHandle |
| 2 | +import { watchEffect, ref } from "vue"; // watchEffect: (effect: WatchEffect, options?: WatchEffectOptions | undefined) => WatchHandle, watchEffect: (effect: WatchEffect, options?: WatchEffectOptions | undefined) => WatchHandle, ref: { <T>(value: T): [T] extends [Ref<any, any>] ? IfAny<T, Ref<T, T>, T> : Ref<UnwrapRef<T>, T | UnwrapRef<T>>; <T = any>(): Ref<...>; }, ref: { <T>(value: T): [T] extends [Ref<any, any>] ? IfAny<T, Ref<T, T>, T> : Ref<UnwrapRef<T>, T | UnwrapRef<T>>; <T = any>(): Ref<...>; } |
| 3 | +import Foo from "./component.vue"; // Foo: DefineComponent<{}, { exposeA: Ref<number, number>; exposeFn: () => Ret | null; exposeFn2: () => number; }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ... 12 more ..., any> |
| 4 | +type VMFoo = InstanceType<typeof Foo>; // VMFoo: CreateComponentPublicInstanceWithMixins<ToResolvedProps<{}, {}>, { exposeA: Ref<number, number>; exposeFn: () => Ret | null; exposeFn2: () => number; }, {}, {}, {}, ComponentOptionsMixin, ... 19 more ..., {}>, InstanceType: InstanceType<T>, Foo: DefineComponent<{}, { exposeA: Ref<number, number>; exposeFn: () => Ret | null; exposeFn2: () => number; }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ... 12 more ..., any> |
| 5 | +let a = ref<VMFoo | null>(null); // a: Ref<CreateComponentPublicInstanceWithMixins<ToResolvedProps<{}, {}>, { exposeA: Ref<number, number>; exposeFn: () => Ret | null; exposeFn2: () => number; }, {}, {}, {}, ComponentOptionsMixin, ... 19 more ..., {}> | null, CreateComponentPublicInstanceWithMixins<...> | null>, ref<VMFoo | null>(null): Ref<CreateComponentPublicInstanceWithMixins<ToResolvedProps<{}, {}>, { exposeA: Ref<number, number>; exposeFn: () => Ret | null; exposeFn2: () => number; }, {}, {}, {}, ComponentOptionsMixin, ... 19 more ..., {}> | null, CreateComponentPublicInstanceWithMixins<...> | null> |
| 6 | +watchEffect(() => { // watchEffect(() => { if (a.value) fn(a); }): WatchHandle |
7 | 7 | if (a.value) fn(a);
|
8 | 8 | });
|
9 | 9 |
|
10 |
| -const comp = {} as VMFoo | undefined; // comp: CreateComponentPublicInstance<Readonly<ExtractPropTypes<{}>>, { exposeA: Ref<number>; exposeFn: () => Ret | null; exposeFn2: () => number; }, {}, {}, {}, ComponentOptionsMixin, ... 13 more ..., {}> | undefined, VMFoo: CreateComponentPublicInstance<Readonly<ExtractPropTypes<{}>>, { exposeA: Ref<number>; exposeFn: () => Ret | null; exposeFn2: () => number; }, {}, {}, {}, ComponentOptionsMixin, ... 13 more ..., {}> |
| 10 | +const comp = {} as VMFoo | undefined; // comp: CreateComponentPublicInstanceWithMixins<ToResolvedProps<{}, {}>, { exposeA: Ref<number, number>; exposeFn: () => Ret | null; exposeFn2: () => number; }, {}, {}, {}, ComponentOptionsMixin, ... 19 more ..., {}> | undefined, VMFoo: CreateComponentPublicInstanceWithMixins<ToResolvedProps<{}, {}>, { exposeA: Ref<number, number>; exposeFn: () => Ret | null; exposeFn2: () => number; }, {}, {}, {}, ComponentOptionsMixin, ... 19 more ..., {}> |
11 | 11 | const r = comp?.exposeFn(); // r: Ret | null | undefined, comp?.exposeFn(): Ret | null | undefined
|
12 | 12 | const r2 = r?.num(); // r2: number | undefined, r?.num(): number | undefined
|
13 | 13 | console.log(r2); // console.log(r2): void
|
14 | 14 |
|
15 |
| -function fn(vm: VMFoo) { // fn: (vm: CreateComponentPublicInstance<Readonly<ExtractPropTypes<{}>>, { exposeA: Ref<number>; exposeFn: () => Ret | null; exposeFn2: () => number; }, {}, {}, {}, ComponentOptionsMixin, ... 13 more ..., {}>) => void, vm: CreateComponentPublicInstance<Readonly<ExtractPropTypes<{}>>, { exposeA: Ref<number>; exposeFn: () => Ret | null; exposeFn2: () => number; }, {}, {}, {}, ComponentOptionsMixin, ... 13 more ..., {}> |
| 15 | +function fn(vm: VMFoo) { // fn: (vm: CreateComponentPublicInstanceWithMixins<ToResolvedProps<{}, {}>, { exposeA: Ref<number, number>; exposeFn: () => Ret | null; exposeFn2: () => number; }, {}, {}, {}, ComponentOptionsMixin, ... 19 more ..., {}>) => void, vm: CreateComponentPublicInstanceWithMixins<ToResolvedProps<{}, {}>, { exposeA: Ref<number, number>; exposeFn: () => Ret | null; exposeFn2: () => number; }, {}, {}, {}, ComponentOptionsMixin, ... 19 more ..., {}> |
16 | 16 | const b = vm.exposeA; // b: number, vm.exposeA: number
|
17 | 17 | console.log(b); // console.log(b): void
|
18 | 18 | const c = vm.exposeFn(); // c: Ret | null, vm.exposeFn(): Ret | null
|
|
0 commit comments