Skip to content

Commit

Permalink
fix: 修复react18.3带来的类型报错问题
Browse files Browse the repository at this point in the history
  • Loading branch information
JackySoft committed Nov 25, 2024
1 parent ed5a698 commit d4a169d
Show file tree
Hide file tree
Showing 5 changed files with 437 additions and 5,698 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
"less": "^4.2.0",
"lodash-es": "^4.17.21",
"qs": "^6.12.1",
"react": "latest",
"react-dom": "latest",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-error-boundary": "^4.0.13",
"react-quill": "^2.0.0",
"react-responsive": "^10.0.0",
Expand All @@ -85,8 +85,8 @@
},
"devDependencies": {
"@types/lodash-es": "^4.17.7",
"@types/react": "latest",
"@types/react-dom": "latest",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"cross-env": "^7.0.3",
"lint-staged": "^10.0.7",
"only-allow": "^1.2.1",
Expand Down
9 changes: 6 additions & 3 deletions packages/editor/src/packages/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface ComItemType {
* @param {events} api 组件自带的事件
* @param {elements} elements 子组件
*/
export interface ComponentType<T = any> {
export type ComponentType<T = any> = {
id: string;
type: string;
name: string;
Expand All @@ -58,8 +58,11 @@ export interface ComponentType<T = any> {
methods: ComponentMethodType[];
apis: { [key: string]: ApiType };
elements: ComponentType<T>[];
[key: string]: any; // 自定义属性,比如事件函数挂载
}
} & OnProps<string>;

type OnProps<TKeys extends string> = {
[P in `on${TKeys}` as `on${TKeys}`]: (data?: any) => void;
};

/**
* 组件配置类型
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default defineConfig({
proxy: {
'/api': {
// 如果本地启动后端,请替换为后端地址
target: 'http://mars-api.marsview.cc',
target: 'http://localhost:5000',
changeOrigin: true,
},
},
Expand Down
9 changes: 6 additions & 3 deletions packages/materials/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type ComItemType = Pick<ComponentType, 'id' | 'type' | 'name' | 'parentId
* @param {events} api 组件自带的事件
* @param {elements} elements 子组件
*/
export interface ComponentType<T = any> {
export type ComponentType<T = any> = {
id: string;
type: string;
name: string | number;
Expand All @@ -50,8 +50,11 @@ export interface ComponentType<T = any> {
methods: ComponentMethodType[];
apis: { [key: string]: ApiType };
elements: ComponentType<T>[];
[key: string]: any; // 自定义属性,比如事件函数挂载
}
} & OnProps<string>;

type OnProps<TKeys extends string> = {
[P in `on${TKeys}` as `on${TKeys}`]: (data?: any) => void;
};

/**
* 组件配置类型
Expand Down
Loading

0 comments on commit d4a169d

Please sign in to comment.