+ Removed the declare module 'jsbn' {
+ Added export as namespace jsbn;
+ export RandomGenerator and Reduction interface
2. Tested in a library package.
3. Tested in an application that installs the library package.
Issue:
Error in @types/jsbn Typescript declarations file.
Symptom:
After installing typescript, jsbn and @types/jsbn in a project,
creation of a Typescript file that import of BigInteger with
import {BigInteger} from 'jsbn';
results in
TS2306: File <path-to>node_modules/@types/jsbn/index.d.ts is not a module.
Resolution:
In @types/jsbn/index.d.ts, replace line
declare namespace jsbn {
with
declare module 'jsbn' {
Additional Notes:
When using current @types/jsbn as is,
using Webstorm's "quickfix" to resolve a reference to BigInteger
example: const bi = new BigInteger('2', 16);
may result in adding
import BigInteger = jsbn.BigInteger;
which will work with local builds but if it becomes a published npm
package (lets call it zzz), a browser-side application (e.g. Angular)
importing package zzz will result in a JavaScript runtime error
as it is unable to resolve 'jsbn.BigInteger'.