File: abstractPropertyNegative.js

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (128 lines) | stat: -rw-r--r-- 3,893 bytes parent folder | download | duplicates (2)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//// [abstractPropertyNegative.ts]
interface A {
    prop: string;
    m(): string;
}
abstract class B implements A {
    abstract prop: string;
    public abstract readonly ro: string;
    abstract get readonlyProp(): string;
    abstract m(): string;
    abstract get mismatch(): string;
    abstract set mismatch(val: number); // error, not same type
}
class C extends B {
    readonly ro = "readonly please";
    abstract notAllowed: string;
    get concreteWithNoBody(): string;
}
let c = new C();
c.ro = "error: lhs of assignment can't be readonly";

abstract class WrongTypeProperty {
    abstract num: number;
}
class WrongTypePropertyImpl extends WrongTypeProperty {
    num = "nope, wrong";
}
abstract class WrongTypeAccessor {
    abstract get num(): number;
}
class WrongTypeAccessorImpl extends WrongTypeAccessor {
    get num() { return "nope, wrong"; }
}
class WrongTypeAccessorImpl2 extends WrongTypeAccessor {
    num = "nope, wrong";
}

abstract class AbstractAccessorMismatch {
    abstract get p1(): string;
    set p1(val: string) { };
    get p2(): string { return "should work"; }
    abstract set p2(val: string);
}


//// [abstractPropertyNegative.js]
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var B = (function () {
    function B() {
    }
    return B;
}());
var C = (function (_super) {
    __extends(C, _super);
    function C() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.ro = "readonly please";
        return _this;
    }
    Object.defineProperty(C.prototype, "concreteWithNoBody", {
        get: function () { },
        enumerable: true,
        configurable: true
    });
    return C;
}(B));
var c = new C();
c.ro = "error: lhs of assignment can't be readonly";
var WrongTypeProperty = (function () {
    function WrongTypeProperty() {
    }
    return WrongTypeProperty;
}());
var WrongTypePropertyImpl = (function (_super) {
    __extends(WrongTypePropertyImpl, _super);
    function WrongTypePropertyImpl() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.num = "nope, wrong";
        return _this;
    }
    return WrongTypePropertyImpl;
}(WrongTypeProperty));
var WrongTypeAccessor = (function () {
    function WrongTypeAccessor() {
    }
    return WrongTypeAccessor;
}());
var WrongTypeAccessorImpl = (function (_super) {
    __extends(WrongTypeAccessorImpl, _super);
    function WrongTypeAccessorImpl() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(WrongTypeAccessorImpl.prototype, "num", {
        get: function () { return "nope, wrong"; },
        enumerable: true,
        configurable: true
    });
    return WrongTypeAccessorImpl;
}(WrongTypeAccessor));
var WrongTypeAccessorImpl2 = (function (_super) {
    __extends(WrongTypeAccessorImpl2, _super);
    function WrongTypeAccessorImpl2() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.num = "nope, wrong";
        return _this;
    }
    return WrongTypeAccessorImpl2;
}(WrongTypeAccessor));
var AbstractAccessorMismatch = (function () {
    function AbstractAccessorMismatch() {
    }
    Object.defineProperty(AbstractAccessorMismatch.prototype, "p1", {
        set: function (val) { },
        enumerable: true,
        configurable: true
    });
    ;
    Object.defineProperty(AbstractAccessorMismatch.prototype, "p2", {
        get: function () { return "should work"; },
        enumerable: true,
        configurable: true
    });
    return AbstractAccessorMismatch;
}());