File tree Expand file tree Collapse file tree 2 files changed +96
-4
lines changed
tests/baselines/reference Expand file tree Collapse file tree 2 files changed +96
-4
lines changed Original file line number Diff line number Diff line change @@ -15412,14 +15412,13 @@ namespace ts {
15412
15412
15413
15413
function isNodeWithinClass(node: Node, classDeclaration: ClassLikeDeclaration) {
15414
15414
while (true) {
15415
- const containingClass = getContainingClass(node);
15416
- if (!containingClass ) {
15415
+ node = getContainingClass(node);
15416
+ if (!node ) {
15417
15417
return false;
15418
15418
}
15419
- if (containingClass === classDeclaration) {
15419
+ if (node === classDeclaration) {
15420
15420
return true;
15421
15421
}
15422
- node = containingClass;
15423
15422
}
15424
15423
}
15425
15424
Original file line number Diff line number Diff line change
1
+ //// [classConstructorAccessibility4.ts]
2
+
3
+ class A {
4
+ private constructor ( ) { }
5
+
6
+ method ( ) {
7
+ class B {
8
+ method ( ) {
9
+ new A ( ) ; // OK
10
+ }
11
+ }
12
+
13
+ class C extends A { // OK
14
+ }
15
+ }
16
+ }
17
+
18
+ class D {
19
+ protected constructor ( ) { }
20
+
21
+ method ( ) {
22
+ class E {
23
+ method ( ) {
24
+ new D ( ) ; // OK
25
+ }
26
+ }
27
+
28
+ class F extends D { // OK
29
+ }
30
+ }
31
+ }
32
+
33
+ //// [classConstructorAccessibility4.js]
34
+ var __extends = ( this && this . __extends ) || function ( d , b ) {
35
+ for ( var p in b ) if ( b . hasOwnProperty ( p ) ) d [ p ] = b [ p ] ;
36
+ function __ ( ) { this . constructor = d ; }
37
+ d . prototype = b === null ? Object . create ( b ) : ( __ . prototype = b . prototype , new __ ( ) ) ;
38
+ } ;
39
+ var A = ( function ( ) {
40
+ function A ( ) {
41
+ }
42
+ A . prototype . method = function ( ) {
43
+ var B = ( function ( ) {
44
+ function B ( ) {
45
+ }
46
+ B . prototype . method = function ( ) {
47
+ new A ( ) ; // OK
48
+ } ;
49
+ return B ;
50
+ } ( ) ) ;
51
+ var C = ( function ( _super ) {
52
+ __extends ( C , _super ) ;
53
+ function C ( ) {
54
+ _super . apply ( this , arguments ) ;
55
+ }
56
+ return C ;
57
+ } ( A ) ) ;
58
+ } ;
59
+ return A ;
60
+ } ( ) ) ;
61
+ var D = ( function ( ) {
62
+ function D ( ) {
63
+ }
64
+ D . prototype . method = function ( ) {
65
+ var E = ( function ( ) {
66
+ function E ( ) {
67
+ }
68
+ E . prototype . method = function ( ) {
69
+ new D ( ) ; // OK
70
+ } ;
71
+ return E ;
72
+ } ( ) ) ;
73
+ var F = ( function ( _super ) {
74
+ __extends ( F , _super ) ;
75
+ function F ( ) {
76
+ _super . apply ( this , arguments ) ;
77
+ }
78
+ return F ;
79
+ } ( D ) ) ;
80
+ } ;
81
+ return D ;
82
+ } ( ) ) ;
83
+
84
+
85
+ //// [classConstructorAccessibility4.d.ts]
86
+ declare class A {
87
+ private constructor ( ) ;
88
+ method ( ) : void ;
89
+ }
90
+ declare class D {
91
+ protected constructor ( ) ;
92
+ method ( ) : void ;
93
+ }
You can’t perform that action at this time.
0 commit comments