( signature: string | undefined | null, memberName: string | null )
| 44 | * (`= { run: impl }` for `api.run()`), including ES shorthand (`= { impl }`). |
| 45 | */ |
| 46 | export function aliasTargetName( |
| 47 | signature: string | undefined | null, |
| 48 | memberName: string | null |
| 49 | ): string | null { |
| 50 | if (!signature) return null; |
| 51 | const initializer = signature.trim(); |
| 52 | |
| 53 | if (memberName) { |
| 54 | const key = escapeRegExp(memberName); |
| 55 | const explicit = new RegExp(`[{,]\\s*${key}\\s*:\\s*([A-Za-z_$][\\w$]*)\\s*[,}]`).exec(initializer); |
| 56 | if (explicit) return explicit[1]!; |
| 57 | // `{ impl }` — shorthand binds the property to the same-named symbol. |
| 58 | const shorthand = new RegExp(`[{,]\\s*(${key})\\s*[,}]`).exec(initializer); |
| 59 | if (shorthand) return shorthand[1]!; |
| 60 | return null; |
| 61 | } |
| 62 | |
| 63 | const bare = BARE_ALIAS_RE.exec(initializer); |
| 64 | return bare ? bare[1]! : null; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * The callable an alias binding forwards to. |
no test coverage detected