Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Prevent passing a plugin that requires props without props #2937

Merged
merged 2 commits into from
Nov 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/config/src/plugins/core-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ function ensureArray<T>(input: T | T[]): T[] {
return [input];
}

type AppliedConfigPlugin<T> = ConfigPlugin<T> | [ConfigPlugin<T>, T];

/**
* Plugin to chain a list of plugins together.
*
* @param config exported config
* @param plugins list of config config plugins to apply to the exported config
*/
export const withPlugins: ConfigPlugin<AppliedConfigPlugin<any>[]> = (
config,
// TODO: Type this somehow if possible.
plugins
): ExportedConfig => {
export const withPlugins: ConfigPlugin<
(
| ConfigPlugin
// TODO: Type this somehow if possible.
| [ConfigPlugin<any>, any]
)[]
> = (config, plugins): ExportedConfig => {
return plugins.reduce((prev, curr) => {
const [plugins, args] = ensureArray(curr);
return plugins(prev, args);
Expand Down