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

zipWithPassword method results in TypeScript type error (ts-2345) when passed string for encryptionType #327

Open
pvburger opened this issue Jan 24, 2025 · 0 comments

Comments

@pvburger
Copy link

pvburger commented Jan 24, 2025

Describe the bug
TypeScript linter flags the string passed in for the encryptionType parameter when invoking the zipWithPassword method

To Reproduce
If I invoke zipWithPassword as follows:
await zipWithPassword(source, target, password, 'AES-256')
TypeScript complains:
Argument of type '"AES-256"' is not assignable to parameter of type 'encryptionMethods | undefined'. ts(2345)

Expected behavior
No TypeScript errors for relevant strings passed in for encryptionMethods parameter.

Env (please complete the following information):

  • Device:
  • OS: Linux
  • OS Version: Linux Mint 20.2
  • Package Version: 7.0.1

Additional context
I believe you've incorrectly implemented your enum in your index.d.ts. The correct implementation should be:
enum EncryptionMethods { STANDARD = "STANDARD", AES_128 = "AES-128", AES_256 = "AES-256" }
If I edit your types declaration as above, everything works as expected and TypeScript is happy. For context, I'm running an Android emulator using Android Studio. When invoking zipWithPassword, I am passing a single file as source, so it's enclosed in an array, as per documentation.

pvburger added a commit to pvburger/react-native-zip-archive that referenced this issue Jan 24, 2025
@pvburger pvburger changed the title zipWithPassword method does not work when passed encryption type as string zipWithPassword method results in TypeScript type error (ts-2345) when passed string for encryptionType Jan 25, 2025
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

No branches or pull requests

1 participant