Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): make the plugins type looser to avoid type mismatch #4550

Merged
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions .changeset/few-ladybugs-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@modern-js/core': patch
---

fix(core): make the plugins type looser to avoid type mismatch

fix(core): 使用更松散的 plugins 类型来避免 type 不匹配的问题
4 changes: 2 additions & 2 deletions packages/cli/core/src/types/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type UserConfig<
// eslint-disable-next-line @typescript-eslint/ban-types
ExtendNormalizedConfig extends Record<string, any> = {},
> = {
plugins?: PluginConfig<any>;
plugins?: PluginConfig;

/**
* auto load plugin that exist in the package.json
Expand All @@ -42,7 +42,7 @@ export type NormalizedConfig<
// eslint-disable-next-line @typescript-eslint/ban-types
} = {},
> = {
plugins: PluginConfig<any>;
plugins: PluginConfig;

/**
* Auto load plugin that exist in the package.json
Expand Down
21 changes: 6 additions & 15 deletions packages/cli/core/src/types/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,10 @@ export type PluginItem = string | [string, any];
*/
export type OldPluginConfig = Array<PluginItem>;

export type NewPluginConfig<
PluginTypes extends {
hooks?: Record<string, any>;
userConfig?: Record<string, any>;
normalizedConfig?: Record<string, any>;
},
> = CliPlugin<PluginTypes>[];
/**
* The type of PluginOptions is looser than the actual type,
* this avoids potential type mismatch issues when using different version plugins.
*/
export type NewPluginConfig = PluginOptions<any, (...args: any[]) => void>[];

export type PluginConfig<
PluginTypes extends {
hooks?: Record<string, any>;
userConfig?: Record<string, any>;
normalizedConfig?: Record<string, any>;
// eslint-disable-next-line @typescript-eslint/ban-types
} = {},
> = OldPluginConfig | NewPluginConfig<PluginTypes>;
export type PluginConfig = OldPluginConfig | NewPluginConfig;
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
---
title: 添加业务模型(状态管理)
---

# 添加业务模型(状态管理)
# 添加状态管理

上一章节中,我们把硬编码的 `mockData` 改成从 Data Loader 中加载。

Expand Down