(directives: DirectiveDef<unknown>[])
| 566 | } |
| 567 | |
| 568 | function assertNoDuplicateDirectives(directives: DirectiveDef<unknown>[]): void { |
| 569 | // The array needs at least two elements in order to have duplicates. |
| 570 | if (directives.length < 2) { |
| 571 | return; |
| 572 | } |
| 573 | |
| 574 | const seenDirectives = new Set<DirectiveDef<unknown>>(); |
| 575 | |
| 576 | for (const current of directives) { |
| 577 | if (seenDirectives.has(current)) { |
| 578 | throw new RuntimeError( |
| 579 | RuntimeErrorCode.DUPLICATE_DIRECTIVE, |
| 580 | `Directive ${current.type.name} matches multiple times on the same element. ` + |
| 581 | `Directives can only match an element once.`, |
| 582 | ); |
| 583 | } |
| 584 | seenDirectives.add(current); |
| 585 | } |
| 586 | } |
no test coverage detected
searching dependent graphs…