File: superCallParameterContextualTyping3.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 (64 lines) | stat: -rw-r--r-- 1,639 bytes parent folder | download | duplicates (5)
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
=== tests/cases/conformance/expressions/contextualTyping/superCallParameterContextualTyping3.ts ===
interface ContextualType<T> {
    method(parameter: T): void;
>method : (parameter: T) => void
>parameter : T
}

class CBase<T>  {
>CBase : CBase<T>

    constructor(param: ContextualType<T>) {
>param : ContextualType<T>
    }

    foo(param: ContextualType<T>) {
>foo : (param: ContextualType<T>) => void
>param : ContextualType<T>
    }
}

class C extends CBase<string> {
>C : C
>CBase : CBase<string>

    constructor() {
        // Should be okay.
        // 'p' should have type 'string'.
        super({
>super({            method(p) {                p.length;            }        }) : void
>super : typeof CBase
>{            method(p) {                p.length;            }        } : { method(p: string): void; }

            method(p) {
>method : (p: string) => void
>p : string

                p.length;
>p.length : number
>p : string
>length : number
            }
        });

        // Should be okay.
        // 'p' should have type 'string'.
        super.foo({
>super.foo({            method(p) {                p.length;            }        }) : void
>super.foo : (param: ContextualType<string>) => void
>super : CBase<string>
>foo : (param: ContextualType<string>) => void
>{            method(p) {                p.length;            }        } : { method(p: string): void; }

            method(p) {
>method : (p: string) => void
>p : string

                p.length;
>p.length : number
>p : string
>length : number
            }
        });
    }
}