(alias: string, def: unknown)
| 563 | } |
| 564 | |
| 565 | protected preparseEntry(alias: string, def: unknown): AliasDefEntry { |
| 566 | const firstParamIndex = alias.indexOf("<") |
| 567 | if (firstParamIndex === -1) { |
| 568 | if (hasArkKind(def, "module") || hasArkKind(def, "generic")) |
| 569 | return [alias, def] |
| 570 | |
| 571 | const qualifiedName = |
| 572 | this.name === "ark" ? alias |
| 573 | : alias === "root" ? this.name |
| 574 | : `${this.name}.${alias}` |
| 575 | |
| 576 | const configured = (def: unknown) => { |
| 577 | const config = this.keywordConfigOf(qualifiedName) |
| 578 | return config ? ([def, "@", config] satisfies TupleExpression) : def |
| 579 | } |
| 580 | |
| 581 | if (!isThunk(def)) return [alias, configured(def)] |
| 582 | // a thunk reads its config when called, so ark doesn't fix it |
| 583 | return [ |
| 584 | alias, |
| 585 | () => { |
| 586 | const resolution = def() |
| 587 | if (hasArkKind(resolution, "generic")) return resolution |
| 588 | return configured(resolution) |
| 589 | } |
| 590 | ] |
| 591 | } |
| 592 | |
| 593 | if (alias[alias.length - 1] !== ">") { |
| 594 | throwParseError( |
| 595 | `'>' must be the last character of a generic declaration in a scope` |
| 596 | ) |
| 597 | } |
| 598 | |
| 599 | const name = alias.slice(0, firstParamIndex) |
| 600 | if (hasArkKind(def, "generic")) |
| 601 | throwParseError(writeParameterizedGenericKeyMessage(name)) |
| 602 | const paramString = alias.slice(firstParamIndex + 1, -1) |
| 603 | const genericName = name[0] === "#" ? name.slice(1) : name |
| 604 | |
| 605 | return [ |
| 606 | name, |
| 607 | // use a thunk definition for the generic so that we can parse |
| 608 | // constraints within the current scope |
| 609 | new LazyGenericRoot( |
| 610 | () => |
| 611 | parseGeneric( |
| 612 | this.parseGenericParams(paramString, { alias: genericName }), |
| 613 | def, |
| 614 | this as never, |
| 615 | genericName |
| 616 | ), |
| 617 | { attach: { paramsDef: paramString, bodyDef: def } } |
| 618 | ) |
| 619 | ] |
| 620 | } |
| 621 | |
| 622 | parseGenericParams( |
nothing calls this directly
no test coverage detected