Closed sinewave440hz closed 5 years ago
Both entries exist so you can import two ways and still get types:
1) import crypto from 'isomorphic-webcrypto';
2) const crypto = require('isomorphic-webcrypto');
I imagine you stop getting types on the ES6 import example if you remove the default export. I think you'd have to import like this:
import * as crypto from 'isomorphic-webcrypto';
Seems related to a breaking change introduced in TypeScript 2.7
I'm hesitant to remove the default statement unless both scenarios above work, so we'll probably have to find another solution.
Ah ok. With my tsconfig I have to have one or the other - this is another thing that I suppose a working example might avoid, if an example tsconfig is supplied... In either case, ensureSecure() is not available in the types (with my ts/tsconfig, at least). Also, getRandomValues() requires an argument (I am told by ts ;) ). What version of typescript did you develop against btw?
re: ensureSecure
- I'll need to add it
re: getRandomValues
- Yeah, I should def fix that in the docs
re: TypeScript version - I didn't develop using TypeScript. I used the intellisense in VSCode to determine whether types were available. I believe my version was backed by 2.6
I'll include an example using TypeScript to clear this up.
I set up a React Native TypeScript example with typescript@3.4.5
and I've added the ensureSecure
method.
Hope this helps. Closing for now.
node_modules/isomorphic-webcrypto/index.d.ts(2,1): error TS2309: An export assignment cannot be used in a module with other exported elements.
Removing the default export stops typescript complaining. (I'm on typescript 2.7.2)