-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat(types): resolves error types incompability with imt-blueprint #16
Conversation
Unit Test Coverage Report
|
Generated |
@@ -25,10 +25,12 @@ | |||
"url": "https://github.com/integromat/imt-proto" | |||
}, | |||
"license": "MIT", | |||
"dependencies": { | |||
"@types/request": "^2.48.12" |
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.
The request type is part of the interface of the Hook. By not including the type in the dependencies, you get typescript error. This issue haven't surfaced yet, because most of the repositories depend on something (like express) that bring in this dependency. But by using the package in imt-blueprint it surfaced
@@ -9,20 +9,23 @@ declare global { | |||
bundle?: Bundle; | |||
suberrors?: Error[]; | |||
external?: any; | |||
|
|||
imtExceptionHash?: string; // moved from imt-blueprint - it is the same thing as hash, it is just a historical inconsistency | |||
imtInternalError?: Error; // moved from imt-blueprint |
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.
Basically this is used just in blueprint I guess to distinguish distinguish: "file not loaded" from node and "Failed to load package" that is the actual intent. Imho it is a bad idea and if I was designing it, I would just translate the error to the "Failed to load package" and add the "file not loaded" to the "cause", but decided to keep it here for backwards compatibilty
7f00e56
to
f2bbf8b
Compare
toJSON() { | ||
return Object.assign(super.toJSON(), this); | ||
toJSON(): ErrorJSON { | ||
return { ...this, ...super.toJSON() }; |
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.
Imho this
should be first and I would bet it caused unexpected behaviour on serialized properties. You called super.toJSON() that would for example serialize the suberrors, but then this object assign over them unserialized.
@@ -453,7 +468,22 @@ Object.defineProperty(Error.prototype, 'toJSON', { | |||
if (this.bundle != null) json.bundle = this.bundle; | |||
if (Array.isArray(this.suberrors)) json.suberrors = this.suberrors.map((item: Error) => item.toJSON()); |
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.
I wonder if this is even necessary, cause I would expect the JSON.stringify() to actually go through all of the items in the array and call toJSON on them. I wonder why we are doing it manually here, but @skvelymake taught me not to touch such kind of things here :D
@@ -45,6 +45,7 @@ declare global { | |||
var IMTRPC: typeof publicApi.IMTRPC; | |||
var IMTFeeder: typeof publicApi.IMTFeeder; | |||
var IMTTransformer: typeof publicApi.IMTTransformer; | |||
var IMTHITL: typeof publicApi.IMTHITL; |
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.
This was for some reason missing, but the blueprint has this line of code that depends on this in global:
Seems like we forgot to add it when doing some refactoring
if (klass.prototype instanceof IMTHITL)
message: 'Type message.', | ||
stack: ee.stack, | ||
}, | ||
imtExceptionHash: 'im-hash', |
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.
Not super happy about repeating this one. I was thinking about not serializing it and keeping just the hash, but I guess something in datadog could depend on it for projects that assign this value.
cb05b04
to
f1fa79b
Compare
@@ -9,7 +9,7 @@ | |||
"integromat", | |||
"imt" | |||
], | |||
"version": "2.4.0", | |||
"version": "2.5.0", |
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.
Unless you see something here that would require a Major version bump. To me seems like minor
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.
I like the changes.
Unfortunatelly I feel there will be more of these...
@@ -9,7 +9,7 @@ | |||
"integromat", | |||
"imt" | |||
], | |||
"version": "2.4.0", | |||
"version": "2.5.0", |
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.
I tend to do version bump in a separate commit, but if you are going to release the library I think that's fine.
Co-authored-by: skvelymake <112627159+skvelymake@users.noreply.github.com>
https://make.atlassian.net/browse/CDM-12048
both proto and imt-bluperint override global error in incompatible ways. When both packages are included in a single project, you get a typescript error.
See comments inline for more explanation