You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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?
The text was updated successfully, but these errors were encountered:
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:
cp
over that file*.test.d.ts
not just*.d.ts
deriveKey
asprivate
- (This is to preventcrypto-js
types leaking through)DeriveKeyOpts
as mandatory, and make the constructor argument be aPartial<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?
The text was updated successfully, but these errors were encountered: