-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
chore: change request.body and ctx.config type #2145
Conversation
Codecov Report
@@ Coverage Diff @@
## typings #2145 +/- ##
========================================
Coverage 99.59% 99.59%
========================================
Files 29 29
Lines 743 743
========================================
Hits 740 740
Misses 3 3 Continue to review full report at Codecov.
|
@@ -39,8 +39,6 @@ export interface Logger { | |||
error(info: string | Error, ...args: any[]): void; | |||
} | |||
|
|||
export type RequestArrayBody = any[]; | |||
export type RequestObjectBody = { [key: string]: any }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这 2 个干掉的话会不会 break ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个没必要用了吧,只有 request.body 可能用上
index.d.ts
Outdated
@@ -22,7 +22,7 @@ declare class BaseContextClass { // tslint:disable-line | |||
/** | |||
* Application config object | |||
*/ | |||
config: EggAppConfig; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥要干掉?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
额,现在这样很难用,自定义的时候 ctx.config.xxx 很多时候都没有自定义。上次 @popomore 他们群里讨论决定改成 any 的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以吧,我的想法是,插件那边提供的 config,都提供 merge,应用层的,也自己写 merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是否可以写成
config: { [key: string]: any } & EggAppConfig
或者干脆给 EggAppConfig 加上 [key: string]: any
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
上次讨论是觉得那样,需要写成 class 模式,有些不好,而且麻烦,然后建议都改成 any ,简单粗暴。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
简单粗暴但丢失了 TS 的优点,加个 [key: string]: any
就好了吧。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
插件和应用层不写,那也只是不提示他们而已,至少 egg 内置的要显示吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议给 EggAppConfig 加上 [key: string]: any
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯,改了。一开始没想到,这样确实比较好。
00f7cf9
to
15c2170
Compare
Checklist
npm test
passesAffected core subsystem(s)
Description of change