-
Notifications
You must be signed in to change notification settings - Fork 2k
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
@uppy/core: fix TypeScript errors #5593
base: main
Are you sure you want to change the base?
Conversation
`@ts-expect-error` directive is not needed; nothing wrong with defining `tus` as `undefined`. Do some type narrowing of `err` in catch block to confirm it's an `Error` before returning message.
Diff output filesdiff --git a/packages/@uppy/core/lib/Uppy.js b/packages/@uppy/core/lib/Uppy.js
index b4c89fe..05a12aa 100644
--- a/packages/@uppy/core/lib/Uppy.js
+++ b/packages/@uppy/core/lib/Uppy.js
@@ -520,7 +520,9 @@ export class Uppy {
try {
_classPrivateFieldLooseBase(this, _restricter)[_restricter].validateSingleFile(file);
} catch (err) {
- return err.message;
+ if (err instanceof Error) {
+ return err.message;
+ }
}
return null;
}
@@ -529,7 +531,9 @@ export class Uppy {
try {
_classPrivateFieldLooseBase(this, _restricter)[_restricter].validateAggregateRestrictions(existingFiles, files);
} catch (err) {
- return err.message;
+ if (err instanceof Error) {
+ return err.message;
+ }
}
return null;
} |
Seems like it's needed afterall |
Reinstate ts-expect-error flag, but this time directly above line with expected error
I've updated the file to reinstate the @ts-expect-error flag, but placed it directly above the |
I wonder how much this PR will help because we use |
@ts-expect-error
directive is not needed; nothing wrong with definingtus
asundefined
.Do some type narrowing of
err
in catch block to confirm it's anError
before returning message.Closes #5592