File: vueLikeDataAndPropsInference.types

package info (click to toggle)
node-typescript 5.0.4%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 459,116 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (97 lines) | stat: -rw-r--r-- 3,061 bytes parent folder | download | duplicates (4)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
=== tests/cases/compiler/vueLikeDataAndPropsInference.ts ===
interface Instance {
    _instanceBrand: never
>_instanceBrand : never
}

type DataDef<Data, Props> = (this: Readonly<Props> & Instance) => Data
>DataDef : DataDef<Data, Props>
>this : Readonly<Props> & Instance

type PropsDefinition<T> = {
>PropsDefinition : PropsDefinition<T>

    [K in keyof T]: T[K]
}

interface Options<
    Data = ((this: Instance) => object),
>this : Instance

    PropsDef = {}
    > {
    data?: Data
>data : Data

    props?: PropsDef
>props : PropsDef

    watch?: Record<string, WatchHandler<any>>
>watch : Record<string, WatchHandler<any>>
}

type WatchHandler<T> = (val: T, oldVal: T) => void;
>WatchHandler : WatchHandler<T>
>val : T
>oldVal : T

type ThisTypedOptions<Data, Props> =
>ThisTypedOptions : ThisTypedOptions<Data, Props>

    Options<DataDef<Data, Props>, PropsDefinition<Props>> &
    ThisType<Data & Readonly<Props> & Instance>

declare function test<Data, Props>(fn: ThisTypedOptions<Data, Props>): void;
>test : { <Data, Props>(fn: ThisTypedOptions<Data, Props>): void; (fn: Options<(this: Instance) => object, {}>): void; }
>fn : ThisTypedOptions<Data, Props>

declare function test(fn: Options): void;
>test : { <Data, Props>(fn: ThisTypedOptions<Data, Props>): void; (fn: Options): void; }
>fn : Options<(this: Instance) => object, {}>

test({
>test({    props: {        foo: ''    },    data(): { bar: boolean } {        return {            bar: true        }    },    watch: {        foo(newVal: string, oldVal: string): void {            this.bar = false        }    }}) : void
>test : { <Data, Props>(fn: ThisTypedOptions<Data, Props>): void; (fn: Options<(this: Instance) => object, {}>): void; }
>{    props: {        foo: ''    },    data(): { bar: boolean } {        return {            bar: true        }    },    watch: {        foo(newVal: string, oldVal: string): void {            this.bar = false        }    }} : { props: { foo: string; }; data(this: Readonly<{ foo: string; }> & Instance): {    bar: boolean;}; watch: { foo(newVal: string, oldVal: string): void; }; }

    props: {
>props : { foo: string; }
>{        foo: ''    } : { foo: string; }

        foo: ''
>foo : string
>'' : ""

    },

    data(): { bar: boolean } {
>data : (this: Readonly<{ foo: string; }> & Instance) => {    bar: boolean;}
>bar : boolean

        return {
>{            bar: true        } : { bar: true; }

            bar: true
>bar : true
>true : true
        }
    },

    watch: {
>watch : { foo(newVal: string, oldVal: string): void; }
>{        foo(newVal: string, oldVal: string): void {            this.bar = false        }    } : { foo(newVal: string, oldVal: string): void; }

        foo(newVal: string, oldVal: string): void {
>foo : (newVal: string, oldVal: string) => void
>newVal : string
>oldVal : string

            this.bar = false
>this.bar = false : false
>this.bar : any
>this : any
>bar : any
>false : false
        }
    }
})