Caligatio / jsSHA

A JavaScript/TypeScript implementation of the complete Secure Hash Standard (SHA) family (SHA-1, SHA-224/256/384/512, SHA3-224/256/384/512, SHAKE128/256, cSHAKE128/256, and KMAC128/256) with HMAC.

Home Page:https://caligatio.github.io/jsSHA/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typescript build error

faljse opened this issue · comments

  • jsSHA version: 3.3.0
  • JavaScript engine and version: node18/chrome

tsc compiler complains on import:

Code

import jsSHA from "jssha";

Could not find a declaration file for module 'jssha'.
 'c:/Users/sydfg/projects/xxx/node_modules/jssha/dist/sha.mjs' implicitly has an 'any' type.

  There are types at 'c:/Users/sydfg/projects/xxx/node_modules/jssha/dist/sha.d.ts', 
but this result could not be resolved when respecting package.json "exports". 
The 'jssha' library may need to update its package.json or typings.ts(7016)

adding "types" to packages.json like this fixes the issue for me.

  "exports": {
    ".": {
      "types": "./dist/sha.d.ts",
      "import": "./dist/sha.mjs",
      "require": "./dist/sha.js"
    },
...

The amount of churn in the Javascript/Typescript ecosystem is staggering :(

I just added extra exports for all the types. I'll push v3.3.1 as it appears this is a widespread issue.