mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-10 21:07:52 -05:00
Test that super is tracked in control flow
This commit is contained in:
37
tests/baselines/reference/controlFlowSuperPropertyAccess.js
Normal file
37
tests/baselines/reference/controlFlowSuperPropertyAccess.js
Normal file
@@ -0,0 +1,37 @@
|
||||
//// [controlFlowSuperPropertyAccess.ts]
|
||||
class B {
|
||||
protected m?(): void;
|
||||
}
|
||||
class C extends B {
|
||||
body() {
|
||||
super.m && super.m();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [controlFlowSuperPropertyAccess.js]
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
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() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
C.prototype.body = function () {
|
||||
_super.prototype.m && _super.prototype.m.call(this);
|
||||
};
|
||||
return C;
|
||||
}(B));
|
||||
@@ -0,0 +1,24 @@
|
||||
=== tests/cases/conformance/controlFlow/controlFlowSuperPropertyAccess.ts ===
|
||||
class B {
|
||||
>B : Symbol(B, Decl(controlFlowSuperPropertyAccess.ts, 0, 0))
|
||||
|
||||
protected m?(): void;
|
||||
>m : Symbol(B.m, Decl(controlFlowSuperPropertyAccess.ts, 0, 9))
|
||||
}
|
||||
class C extends B {
|
||||
>C : Symbol(C, Decl(controlFlowSuperPropertyAccess.ts, 2, 1))
|
||||
>B : Symbol(B, Decl(controlFlowSuperPropertyAccess.ts, 0, 0))
|
||||
|
||||
body() {
|
||||
>body : Symbol(C.body, Decl(controlFlowSuperPropertyAccess.ts, 3, 19))
|
||||
|
||||
super.m && super.m();
|
||||
>super.m : Symbol(B.m, Decl(controlFlowSuperPropertyAccess.ts, 0, 9))
|
||||
>super : Symbol(B, Decl(controlFlowSuperPropertyAccess.ts, 0, 0))
|
||||
>m : Symbol(B.m, Decl(controlFlowSuperPropertyAccess.ts, 0, 9))
|
||||
>super.m : Symbol(B.m, Decl(controlFlowSuperPropertyAccess.ts, 0, 9))
|
||||
>super : Symbol(B, Decl(controlFlowSuperPropertyAccess.ts, 0, 0))
|
||||
>m : Symbol(B.m, Decl(controlFlowSuperPropertyAccess.ts, 0, 9))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
=== tests/cases/conformance/controlFlow/controlFlowSuperPropertyAccess.ts ===
|
||||
class B {
|
||||
>B : B
|
||||
|
||||
protected m?(): void;
|
||||
>m : (() => void) | undefined
|
||||
}
|
||||
class C extends B {
|
||||
>C : C
|
||||
>B : B
|
||||
|
||||
body() {
|
||||
>body : () => void
|
||||
|
||||
super.m && super.m();
|
||||
>super.m && super.m() : void | undefined
|
||||
>super.m : (() => void) | undefined
|
||||
>super : B
|
||||
>m : (() => void) | undefined
|
||||
>super.m() : void
|
||||
>super.m : () => void
|
||||
>super : B
|
||||
>m : () => void
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// @strictNullChecks: true
|
||||
class B {
|
||||
protected m?(): void;
|
||||
}
|
||||
class C extends B {
|
||||
body() {
|
||||
super.m && super.m();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user