eXavier eXavier - 1 year ago 503
TypeScript Question

How to import plotly.js into TypeScript?

I'm trying to import

into TypeScript. Plotly.js is installed using
. In my TypeScript file I use

import 'plotly.js';

It's OK but I'm getting error on code like

error TS2304: Cannot find name 'Plotly'

When I try

import Plotly = require('plotly.js');

I'm getting

error TS2307: Cannot find module 'plotly.js'.

Answer Source

Ended up with:

declare function require(moduleName: string): any;
var Plotly = require('plotly.js/lib/index-basic.js');

(Referring to index-basic.js as I need just the basic functionality, use index.js for the full library.)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download