大家好,我不知道如何使用 mixin 正确声明我添加lodash的方法。安装 lodash 和 @types/lodash,代码编译,基本的 lodash 方法被提取。我使用angular cli,typings.d.ts添加到生成
declare module _ {
interface LoDashStatic {
humanize(str: string): string;
}
}
错误如下:Property 'humanize' does not exist on type 'LoDashStatic'。那些。编译器仍然看不到它。我把 mixin 本身放在src/initializers/lodash.js. 该文件的路径在scripts文件 key中指定angular-cli.json。
在英文版中,我找到了对打字工作的详尽描述
https://stackoverflow.com/questions/40222162/typescript-2-custom-typings-for-untyped-npm-module