diff --git a/packages/frontend-plugin-api/src/wiring/createExtension.ts b/packages/frontend-plugin-api/src/wiring/createExtension.ts index 55d71e0d2f..a3be782fc8 100644 --- a/packages/frontend-plugin-api/src/wiring/createExtension.ts +++ b/packages/frontend-plugin-api/src/wiring/createExtension.ts @@ -148,6 +148,29 @@ export interface LegacyCreateExtensionOptions< }): Expand>; } +type ToIntersection = (U extends any ? (k: U) => void : never) extends ( + k: infer I, +) => void + ? I + : never; + +type PopUnion = ToIntersection< + U extends any ? () => U : never +> extends () => infer R + ? [rest: Exclude, next: R] + : undefined; + +/** @ignore */ +type JoinStringUnion< + U, + TDiv extends string = ', ', + TResult extends string = '', +> = PopUnion extends [infer IRest extends string, infer INext extends string] + ? TResult extends '' + ? JoinStringUnion + : JoinStringUnion + : TResult; + /** @ignore */ export type VerifyExtensionFactoryOutput< UDeclaredOutput extends AnyExtensionDataRef, @@ -162,18 +185,12 @@ export type VerifyExtensionFactoryOutput< ? [IRequiredOutputIds] extends [UFactoryOutput['id']] ? [UFactoryOutput['id']] extends [UDeclaredOutput['id']] ? {} - : { - 'Error: The extension factory has undeclared output(s)': Exclude< - UFactoryOutput['id'], - UDeclaredOutput['id'] - >; - } - : { - 'Error: The extension factory is missing the following output(s)': Exclude< - IRequiredOutputIds, - UFactoryOutput['id'] - >; - } + : `Error: The extension factory has undeclared output(s): ${JoinStringUnion< + Exclude + >}` + : `Error: The extension factory is missing the following output(s): ${JoinStringUnion< + Exclude + >}` : never; /** @public */