MCPcopy Create free account
hub / github.com/angular/components / constructor

Method constructor

src/cdk/overlay/overlay-config.ts:83–102  ·  view source on GitHub ↗
(config?: OverlayConfig)

Source from the content-addressed store, hash-verified

81 eventPredicate?: (event: Event) => boolean;
82
83 constructor(config?: OverlayConfig) {
84 if (config) {
85 // Use `Iterable` instead of `Array` because TypeScript, as of 3.6.3,
86 // loses the array generic type in the `for of`. But we *also* have to use `Array` because
87 // typescript won't iterate over an `Iterable` unless you compile with `--downlevelIteration`
88 const configKeys = Object.keys(config) as Iterable<keyof OverlayConfig> &
89 (keyof OverlayConfig)[];
90 for (const key of configKeys) {
91 if (config[key] !== undefined) {
92 // TypeScript, as of version 3.5, sees the left-hand-side of this expression
93 // as "I don't know *which* key this is, so the only valid value is the intersection
94 // of all the possible values." In this case, that happens to be `undefined`. TypeScript
95 // is not smart enough to see that the right-hand-side is actually an access of the same
96 // exact type with the same exact key, meaning that the value type must be identical.
97 // So we use `any` to work around this.
98 this[key] = config[key] as any;
99 }
100 }
101 }
102 }
103}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected