Cannot import svg.js in Typescript

Viewed 1430

I installed svg.js as a dev dependency. It appears in my package.json as svg.js": "^2.6.6".

I can import the library in a javascript file with:

import SVG from 'svg.js';

However, if I do the same thing in a Typescript file, I get the error: "cannot find module svg.js".

I also have a folder called "typings" with the type definition file available on the svg.js website.

Why can't I use this library?

1 Answers

in ES6, you can import it using this code:

import * as SVG from "svg.js";
let draw = SVG('drawing');
let rect = draw.rect(100, 100);

Related