Skip to content

Conversation

@leeyeh
Copy link
Contributor

@leeyeh leeyeh commented Jun 27, 2022

前景提要:

https://github.com/leancloud/ticket/pull/609/files#diff-dec40c8cf82954eb426791bbfd0c151ce050d78f836fabb5cf4afdaccd1e2566L177
#666
#324

尝试了一下让 AV.Error 继承 Error,发现有难度。一是目前的 AV.Error 支持直接(不用 new 关键字)调用,如果用 ES6 class 那么就是个 breaking change 了。二是就算用 ES6 的继承,babel 6 对 Error 继承也有 bug: babel/babel#8385 (这个版本暂时不想升 babel 7)。

所以最终改了定义文件,避免用户写出 error instanceof AV.Error 这样的 type guard。如果用户需要区分出 AV.Error,单独写一个 isAVError 通过判断 error.code 类型作为 type guard。

@leeyeh leeyeh requested review from jysperm and sdjdd June 27, 2022 13:00
@codecov
Copy link

codecov bot commented Jun 27, 2022

Codecov Report

Merging #667 (dda66fb) into master (633636f) will not change coverage.
The diff coverage is n/a.

❗ Current head dda66fb differs from pull request most recent head a11cab9. Consider uploading reports for the commit a11cab9 to get more accurate results

@@ Coverage Diff @@ ## master #667 +/- ## ======================================= Coverage 61.62% 61.62% ======================================= Files 40 40 Lines 3448 3448 ======================================= Hits 2125 2125 Misses 1323 1323 

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 633636f...a11cab9. Read the comment docs.

Co-authored-by: Ayumi Sarah <i@sdjdd.com>
@leeyeh leeyeh merged commit c1f26b2 into master Jun 28, 2022
@leeyeh leeyeh deleted the fix/error-type branch June 28, 2022 10:09
sdjdd added a commit to sdjdd/javascript-sdk that referenced this pull request Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants