Reputation: 21
I have imported crypto pouch in angular like below
import CryptoPouch from 'crypto-pouch';
But its showing error like below,
Could not find a declaration file for module 'crypto-pouch'. '/home/excercise_task/pouchDB/pouchApp/node_modules/crypto-pouch/index.js' implicitly has an 'any' type.
Try npm i --save-dev @types/crypto-pouch
if it exists or add a new declaration (.d.ts) file containing declare module 'crypto-pouch';
ts(7016)
Upvotes: -1
Views: 181
Reputation: 4963
Update
I ended up writing the type definition for crypto-pouch which merged at DefinitelyTyped, so just do this
$ npm install --save-dev @types/crypto-pouch
and don't use the work-around below 👍
// extend PouchDB for the crypto-pouch plugin
declare module "crypto-pouch"; // define the module for this definition
declare namespace PouchDB {
namespace CryptoPouch {
type Options = {
/* A string password, used to encrypt documents. */
password: string;
/* (optional) Array of strings of properties that will not be encrypted. */
ignore?: string[];
};
}
/* Plugin */
interface Database<Content extends {} = {}> {
/**
*
* @param options See CryptoPouch.Options
*/
crypto(options: CryptoPouch.Options): Promise<void>;
/**
*
* @param password A string password, used to encrypt documents.
* @param ignore Array of strings of properties that will not be encrypted.
*/
crypto(password: string, ignore?: string[]): Promise<void>;
/**
* Disables encryption on the database and forgets your password.
*/
removeCrypto(): void;
}
}
Upvotes: 0
Reputation: 796
Change import statement to require:
const CryptoPouch = require('crypto-pouch');
If you get could not find name require like the message below:
Cannot find name 'require'. Do you need to install type definitions for node?
Run:
npm i --save-dev @types/node
Upvotes: 0