Skip to content

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

@Nysosis

Description

@Nysosis

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions