MCPcopy Create free account
hub / github.com/aws/constructs / addChild

Method addChild

src/construct.ts:472–494  ·  view source on GitHub ↗

* Adds a child construct to this node. * * @param child The child construct * @param childName The type name of the child construct. * @returns The resolved path part name of the child

(child: Construct, childName: string)

Source from the content-addressed store, hash-verified

470 * @returns The resolved path part name of the child
471 */
472 private addChild(child: Construct, childName: string) {
473 if (this.locked) {
474
475 // special error if root is locked
476 if (!this.path) {
477 throw new Error('Cannot add children during synthesis');
478 }
479
480 throw new Error(`Cannot add children to "${this.path}" during synthesis`);
481 }
482
483 if (!this._children) {
484 this._children = {};
485 }
486
487 if (this._children[childName]) {
488 const name = this.id ?? '';
489 const typeName = this.host.constructor.name;
490 throw new Error(`There is already a Construct with name '${childName}' in ${typeName}${name.length > 0 ? ' [' + name + ']' : ''}`);
491 }
492
493 this._children[childName] = child;
494 }
495}
496
497/**

Callers 1

constructorMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected