LoginSignup
0
1

More than 3 years have passed since last update.

【TypeScript】@typesが存在しないライブラリのts設定

Posted at

What happened?

@typesをinstallしてない状態でtscすると、 npm install @types/XXXと表示され、エラーになる。
@typesがないライブラリを使ってるときはどうしたらいいの?

Type error: Could not find a declaration file for module 'react-vis'. '/Users/pc148/code/cluster-view/node_modules/react-vis/dist/index.js' implicitly has an 'any' type.
  Try `npm install @types/react-vis` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-vis';`  TS7016

    1 | // @flow
    2 | import React, { Component } from 'react';
  > 3 | import { XYPlot, MarkSeries } from 'react-vis';
      |                                    ^

解決策

型定義ファイルに、declare moduleを追加する。

// react-vis.d.ts
 declare module 'react-vis';</br>

links

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1