【发布时间】:2018-11-09 21:43:07
【问题描述】:
我正在使用fingerprintjs2 库,它在definitelyTyped 中有不完整且不兼容的声明
我选择在我的项目中编写自己的声明,但我正在努力在代码中加载该声明。我仍然收到错误
找不到模块'fingerprintjs2'
在这个导入语句中
import Fingerprint2, { TCallback, TComponent } from 'fingerprintjs2';
我的声明被写成独立模块
// ./src/@types/fingerprintjs2/index.d.ts
// ...some 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[]>;
}
我的 tsconfig.json
{
"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"
}
}
我没有找到关于这将如何工作的明确解释。你能给我一个建议吗?感谢您的帮助。
我在 Webstorm 2018.2 中使用 Typescript 3.1.6
【问题讨论】:
标签: typescript typescript-typings