Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using svg.js with TypeScript

I'm making a website app using TypeScript, and I want to use the svg.js library.

I'm coding in TypeScript, and automatically compiling into JavaScript which runs in the browser.

Is this possible? And if so, how?

like image 926
Magmatic Avatar asked Sep 26 '26 06:09

Magmatic


1 Answers

svg.js provides a .d.ts file so you can use it in typescript out of box.

I am using vscode and it needs no further configuration to provide intellisense.

CommonJS style CommonJS style

ES 6 style ES 6 style or ES 6 style

vscode integrates js and ts service tightly, so it may provide some kind of auto detection. I never used Atom but I think you can explicitly declare your reference using Triple-Slash Directives

/// <reference path="path/to/yourTypeDeclaration.d.ts" />
// your code follows

If importing this still not helps, you may lack some kind of language service plugins.

like image 162
obfish Avatar answered Sep 28 '26 20:09

obfish