I have encountered an issue while using the fingerprintjs2
library, as the declaration provided in DefinitelyTyped seems incomplete and incompatible.
In order to resolve this, I decided to create my own declaration within my project. However, I am facing difficulties when trying to load this custom declaration in my code, resulting in the error:
Cannot find module 'fingerprintjs2'
specifically for this import statement:
import Fingerprint2, { TCallback, TComponent } from 'fingerprintjs2';
The declaration I wrote is isolated within a module, located at
// ./src/@types/fingerprintjs2/index.d.ts
// ...other exported types
export type TComponent = {
key: string;
value: string | number | boolean | string[];
};
export type TCallback = (components: TComponent[]) => void;
export default interface fingerprintjs2 {
get(callback: TCallback): void;
get(options: TOptions, callback: TCallback): void;
getPromise(options: TOptions): Promise<TComponent[]>;
}
This issue persists despite configuring my tsconfig.json file as follows:
{
"include": ["src/**/*"],
"exclude": ["node_modules"],
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"declaration": true,
"declarationDir": "./dist",
"lib": ["dom", "es5", "scripthost"],
"module": "es6",
"noImplicitAny": true,
"outDir": "./dist",
"paths": { "*": ["./src/@types*"] },
"target": "es5"
}
}
I would greatly appreciate any advice or assistance on how to properly address this issue. Thank you for your help.
For reference, I am working with Typescript 3.1.6 in Webstorm 2018.2