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

Can't appear to import library within a typescript file as nothing is exported, additionally the published types don't seem to match with current code #5

Open
Nysosis opened this issue Jan 8, 2025 · 0 comments

Comments

@Nysosis
Copy link

Nysosis commented Jan 8, 2025

Hi,

I'm trying to use this library from a typescript project, however because the .d.ts file doesn't export anything, attempting to import the library results in a File '[root]/node_modules/string-crypto/dist/index.d.ts' is not a module ts(2306) error.

Also, what types are in the index.d.ts aren't quite right, they're referencing a StringLike when the code is only expecting a standard string at this point.

What I've done locally is to:

  • Delete the src/index.d.ts
  • Update the build command to not cp over that file
  • Update the build command to rm *.test.d.ts not just *.d.ts
  • Mark deriveKey as private - (This is to prevent crypto-js types leaking through)
  • Make all types in DeriveKeyOpts as mandatory, and make the constructor argument be a Partial<DeriveKeyOpts> (This is allows specification of only some of the properties on the options, allowing the defaults to apply)

This allows for the d.ts file to be generated from the actual index file, with expected tpyings, which can be consumed from typescript libraries.

Happy to raise a PR with these changes in place :) - unless there's a specific reason things are like they currently are?

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