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

Method defaultChild

src/construct.ts:159–171  ·  view source on GitHub ↗

* Returns the child construct that has the id `Default` or `Resource`. * This is usually the construct that provides the bulk of the underlying functionality. * Useful for modifications of the underlying construct that are not available at the higher levels. * * @throws if there is more

()

Source from the content-addressed store, hash-verified

157 * @returns a construct or undefined if there is no default child
158 */
159 public get defaultChild(): IConstruct | undefined {
160 if (this._defaultChild !== undefined) {
161 return this._defaultChild;
162 }
163
164 const resourceChild = this.tryFindChild('Resource');
165 const defaultChild = this.tryFindChild('Default');
166 if (resourceChild && defaultChild) {
167 throw new Error(`Cannot determine default child for ${this.path}. There is both a child with id "Resource" and id "Default"`);
168 }
169
170 return defaultChild || resourceChild;
171 }
172
173 /**
174 * Override the defaultChild property.

Callers

nothing calls this directly

Calls 1

tryFindChildMethod · 0.95

Tested by

no test coverage detected