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

Fix TypeScript errors #5593

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

EricImpact
Copy link

@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.

Closes #5592

`@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.
Copy link
Contributor

Diff output files
diff --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;
   }

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

Successfully merging this pull request may close these issues.

Incorrect @ts-expect-error comment causes TypeScript error
1 participant