frontend-plugin-api: clean up output mismatch error message

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-08-12 13:49:41 +02:00
parent f4ff0bf617
commit d71c7469c7
@@ -148,6 +148,29 @@ export interface LegacyCreateExtensionOptions<
}): Expand<ExtensionDataValues<TOutput>>;
}
type ToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
k: infer I,
) => void
? I
: never;
type PopUnion<U> = ToIntersection<
U extends any ? () => U : never
> extends () => infer R
? [rest: Exclude<U, R>, next: R]
: undefined;
/** @ignore */
type JoinStringUnion<
U,
TDiv extends string = ', ',
TResult extends string = '',
> = PopUnion<U> extends [infer IRest extends string, infer INext extends string]
? TResult extends ''
? JoinStringUnion<IRest, TDiv, INext>
: JoinStringUnion<IRest, TDiv, `${TResult}${TDiv}${INext}`>
: 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<UFactoryOutput['id'], UDeclaredOutput['id']>
>}`
: `Error: The extension factory is missing the following output(s): ${JoinStringUnion<
Exclude<IRequiredOutputIds, UFactoryOutput['id']>
>}`
: never;
/** @public */