mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Included previously ignored baseline .js file and slight refactoring
This commit is contained in:
parent
2d7a0f4a25
commit
ba8b1680cb
@ -15412,14 +15412,13 @@ namespace ts {
|
||||
|
||||
function isNodeWithinClass(node: Node, classDeclaration: ClassLikeDeclaration) {
|
||||
while (true) {
|
||||
const containingClass = getContainingClass(node);
|
||||
if (!containingClass) {
|
||||
node = getContainingClass(node);
|
||||
if (!node) {
|
||||
return false;
|
||||
}
|
||||
if (containingClass === classDeclaration) {
|
||||
if (node === classDeclaration) {
|
||||
return true;
|
||||
}
|
||||
node = containingClass;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
93
tests/baselines/reference/classConstructorAccessibility4.js
Normal file
93
tests/baselines/reference/classConstructorAccessibility4.js
Normal file
@ -0,0 +1,93 @@
|
||||
//// [classConstructorAccessibility4.ts]
|
||||
|
||||
class A {
|
||||
private constructor() { }
|
||||
|
||||
method() {
|
||||
class B {
|
||||
method() {
|
||||
new A(); // OK
|
||||
}
|
||||
}
|
||||
|
||||
class C extends A { // OK
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class D {
|
||||
protected constructor() { }
|
||||
|
||||
method() {
|
||||
class E {
|
||||
method() {
|
||||
new D(); // OK
|
||||
}
|
||||
}
|
||||
|
||||
class F extends D { // OK
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// [classConstructorAccessibility4.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 A = (function () {
|
||||
function A() {
|
||||
}
|
||||
A.prototype.method = function () {
|
||||
var B = (function () {
|
||||
function B() {
|
||||
}
|
||||
B.prototype.method = function () {
|
||||
new A(); // OK
|
||||
};
|
||||
return B;
|
||||
}());
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return C;
|
||||
}(A));
|
||||
};
|
||||
return A;
|
||||
}());
|
||||
var D = (function () {
|
||||
function D() {
|
||||
}
|
||||
D.prototype.method = function () {
|
||||
var E = (function () {
|
||||
function E() {
|
||||
}
|
||||
E.prototype.method = function () {
|
||||
new D(); // OK
|
||||
};
|
||||
return E;
|
||||
}());
|
||||
var F = (function (_super) {
|
||||
__extends(F, _super);
|
||||
function F() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return F;
|
||||
}(D));
|
||||
};
|
||||
return D;
|
||||
}());
|
||||
|
||||
|
||||
//// [classConstructorAccessibility4.d.ts]
|
||||
declare class A {
|
||||
private constructor();
|
||||
method(): void;
|
||||
}
|
||||
declare class D {
|
||||
protected constructor();
|
||||
method(): void;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user