Encountering an issue while trying to import Svg.js into my TypeScript project. After calling SVG, an error message is displayed:
Uncaught (in promise) TypeError: SVG is not a function
Various approaches have been attempted to import Svg.js without success. Additionally, different methods of calling 'SVG' have been tested.
Current Svg.js version in use is @svgdotjs/svg.js": "^3.0.11
Example:
import * as SVG from "@svgdotjs/svg.js";
const svgjs: any = SVG;
export default svgjs;
let draw = new SVG.Doc('drawing');
let rect = draw.rect(100, 100).attr({fill: "#f06"})
Unfortunately, the above approach triggers an error:
Uncaught (in promise) TypeError: SVG.Doc is not a constructor
Below is the method used for importing Svg.js:
import * as SVG from '@svgdotjs/svg.js'
How 'SVG' is utilized:
let draw = SVG('drawing');
let rect = draw.rect(100, 100).attr({fill: "#f06"})