File: accessorsOverrideProperty8.types

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (78 lines) | stat: -rw-r--r-- 2,417 bytes parent folder | download | duplicates (3)
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
=== tests/cases/conformance/classes/propertyMemberDeclarations/accessorsOverrideProperty8.ts ===
type Types = 'boolean' | 'unknown' | 'string';
>Types : "string" | "boolean" | "unknown"

type Properties<T extends { [key: string]: Types }> = {
>Properties : Properties<T>
>key : string

    readonly [key in keyof T]: T[key] extends 'boolean' ? boolean : T[key] extends 'string' ? string : unknown
}

type AnyCtor<P extends object> = new (...a: any[]) => P
>AnyCtor : AnyCtor<P>
>a : any[]

declare function classWithProperties<T extends { [key: string]: Types }, P extends object>(properties: T, klass: AnyCtor<P>): {
>classWithProperties : <T extends { [key: string]: Types; }, P extends object>(properties: T, klass: AnyCtor<P>) => {    new (): P & Properties<T>;    prototype: P & Properties<T>;}
>key : string
>properties : T
>klass : AnyCtor<P>

    new(): P & Properties<T>;
    prototype: P & Properties<T>
>prototype : P & Properties<T>

};

const Base = classWithProperties({
>Base : { new (): Base & Properties<{ readonly x: "boolean"; y: "string"; }>; prototype: Base & Properties<{ readonly x: "boolean"; y: "string"; }>; }
>classWithProperties({    get x() { return 'boolean' as const },    y: 'string',}, class Base {}) : { new (): Base & Properties<{ readonly x: "boolean"; y: "string"; }>; prototype: Base & Properties<{ readonly x: "boolean"; y: "string"; }>; }
>classWithProperties : <T extends { [key: string]: Types; }, P extends object>(properties: T, klass: AnyCtor<P>) => { new (): P & Properties<T>; prototype: P & Properties<T>; }
>{    get x() { return 'boolean' as const },    y: 'string',} : { readonly x: "boolean"; y: "string"; }

    get x() { return 'boolean' as const },
>x : "boolean"
>'boolean' as const : "boolean"
>'boolean' : "boolean"

    y: 'string',
>y : "string"
>'string' : "string"

}, class Base {
>class Base {} : typeof Base
>Base : typeof Base

});

class MyClass extends Base {
>MyClass : MyClass
>Base : Base & Properties<{ readonly x: "boolean"; y: "string"; }>

    get x() {
>x : boolean

        return false;
>false : false
    }
    get y() {
>y : string

        return 'hi'
>'hi' : "hi"
    }
}

const mine = new MyClass();
>mine : MyClass
>new MyClass() : MyClass
>MyClass : typeof MyClass

const value = mine.x;
>value : boolean
>mine.x : boolean
>mine : MyClass
>x : boolean