File: derivedClassWithoutExplicitConstructor.types

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (81 lines) | stat: -rw-r--r-- 1,247 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
=== tests/cases/conformance/classes/constructorDeclarations/automaticConstructors/derivedClassWithoutExplicitConstructor.ts ===
class Base {
>Base : Base

    a = 1;
>a : number
>1 : 1

    constructor(x: number) { this.a = x; }
>x : number
>this.a = x : number
>this.a : number
>this : this
>a : number
>x : number
}

class Derived extends Base {
>Derived : Derived
>Base : Base

    x = 1
>x : number
>1 : 1

    y = 'hello';
>y : string
>'hello' : "hello"
}

var r = new Derived(); // error
>r : Derived
>new Derived() : Derived
>Derived : typeof Derived

var r2 = new Derived(1); 
>r2 : Derived
>new Derived(1) : Derived
>Derived : typeof Derived
>1 : 1

class Base2<T> {
>Base2 : Base2<T>

    a: T;
>a : T

    constructor(x: T) { this.a = x; }
>x : T
>this.a = x : T
>this.a : T
>this : this
>a : T
>x : T
}

class D<T extends Date> extends Base2<T> {
>D : D<T>
>Base2 : Base2<T>

    x = 2
>x : number
>2 : 2

    y: T = null;
>y : T
>null : null
}

var d = new D(); // error
>d : D<Date>
>new D() : D<Date>
>D : typeof D

var d2 = new D(new Date()); // ok
>d2 : D<Date>
>new D(new Date()) : D<Date>
>D : typeof D
>new Date() : Date
>Date : DateConstructor