【问题标题】:React-web-Vector-icons types issue for typescript打字稿的 React-web-Vector-icons 类型问题
【发布时间】:2021-12-25 07:31:11
【问题描述】:

#34 我已经在 typescript 中安装了这个库来生成类型错误

TS7016:找不到模块“react-web-vector-icons”的声明文件。 '/Users/apple/Documents/GitHub/ProjectAliance/node_modules/react-web-vector-icons/dist/index.js' 隐含了一个 'any' 类型。 如果存在,请尝试 npm i --save-dev @types/react-web-vector-icons 或添加包含 declare module 'react-web-vector-icons' 的新声明 (.d.ts) 文件;

【问题讨论】:

    标签: javascript typescript types


    【解决方案1】:

    我添加了#.d.ts 的文件并有以下代码 它帮助我解决类型问题 创建一个新文件 types.d.ts

    declare module 'react-web-vector-icons' {
    
    export default function Icon({name,size,color,font}:icon):any;
    }
     
    
    interface icon {
    name: string,
    size: number,
    color: string,
    font:string,
    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-21
      • 2022-10-05
      • 2017-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多