@@ -35,7 +35,7 @@ export class Stack extends Construct {
35
35
*/
36
36
public static find ( node : Construct ) : Stack {
37
37
let curr : Construct | undefined = node ;
38
- while ( curr != null && ! isStack ( curr ) ) {
38
+ while ( curr != null && ! Stack . isStack ( curr ) ) {
39
39
curr = curr . parent ;
40
40
}
41
41
@@ -58,6 +58,15 @@ export class Stack extends Construct {
58
58
construct . addMetadata ( 'aws:cdk:physical-name' , physicalName ) ;
59
59
}
60
60
61
+ /**
62
+ * Return whether the given object is a Stack.
63
+ *
64
+ * We do attribute detection since we can't reliably use 'instanceof'.
65
+ */
66
+ public static isStack ( construct : Construct ) : construct is Stack {
67
+ return ( construct as any ) . _isStack ;
68
+ }
69
+
61
70
private static readonly VALID_STACK_NAME_REGEX = / ^ [ A - Z a - z ] [ A - Z a - z 0 - 9 - ] * $ / ;
62
71
63
72
/**
@@ -72,11 +81,6 @@ export class Stack extends Construct {
72
81
*/
73
82
public readonly env : Environment ;
74
83
75
- /**
76
- * Used to determine if this construct is a stack.
77
- */
78
- public readonly isStack = true ;
79
-
80
84
/**
81
85
* Logical ID generation strategy
82
86
*/
@@ -92,6 +96,11 @@ export class Stack extends Construct {
92
96
*/
93
97
public readonly name : string ;
94
98
99
+ /**
100
+ * Used to determine if this construct is a stack.
101
+ */
102
+ protected readonly _isStack = true ;
103
+
95
104
/**
96
105
* Creates a new stack.
97
106
*
@@ -433,15 +442,6 @@ export abstract class Referenceable extends StackElement {
433
442
}
434
443
}
435
444
436
- /**
437
- * Return whether the given object is a Stack.
438
- *
439
- * We do attribute detection since we can't reliably use 'instanceof'.
440
- */
441
- function isStack ( construct : Construct ) : construct is Stack {
442
- return ( construct as any ) . isStack ;
443
- }
444
-
445
445
/**
446
446
* Collect all StackElements from a construct
447
447
*
0 commit comments