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

优化 Base.from 方法声明及调用 #9

Merged
merged 1 commit into from
Dec 2, 2019
Merged

Conversation

beliefgp
Copy link
Contributor

@beliefgp beliefgp commented Nov 19, 2019

  1. 当前子类调用继承的 from 方法,可以正确显示返回的实例类型。
  2. 通过 from 方法,可以和 new 一个实例一样,添加扩展信息,而且参数自动映射。

image

@codecov
Copy link

codecov bot commented Nov 19, 2019

Codecov Report

Merging #9 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master     #9   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          50     50           
  Lines         342    341    -1     
  Branches       48     48           
=====================================
- Hits          342    341    -1
Impacted Files Coverage Δ
lib/base.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d1e43eb...474ba79. Read the comment docs.

@atian25 atian25 requested a review from whxaxes November 19, 2019 16:18
lib/base.ts Show resolved Hide resolved
@whxaxes
Copy link
Member

whxaxes commented Nov 30, 2019

我似乎没这个包的发包权限,@atian25 发一下?

@atian25
Copy link
Member

atian25 commented Nov 30, 2019

我也没有,只有 @popomore

@popomore
Copy link
Member

popomore commented Dec 2, 2019

已经看不懂了

@popomore popomore merged commit fbad6cd into eggjs:master Dec 2, 2019
@popomore
Copy link
Member

popomore commented Dec 2, 2019

  • egg-errors@2.1.1

@popomore
Copy link
Member

popomore commented Dec 2, 2019

@atian25 @whxaxes 加你们两了

@beliefgp
Copy link
Contributor Author

beliefgp commented Dec 2, 2019

😀,主要就是利用 this 的类型,反推出实际调用 from 方法的子类的具体类型。
因为子类继承 BaseError,但是可以有自己独立的构造函数,所以和 typeof BaseError 是有区别的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants