apexcharts.js: Compilation error TS1122 in apexcharts.d.ts

Issue

I can’t import apexcharts on my angular 5.2 project

Explanation

After doing npm install apexcharts --save

When i tried to import the module import {ApexCharts} from 'apexcharts'

I’ve got an error :

TS2305: Module ‘“apexcharts”’ has no exported member ‘ApexCharts’.

apexchart_error_exported_member

So i tried to import all the module import * as ApexCharts from 'apexcharts'

But now, i’ve another error because the apexcharts.d.ts contains an error, it is not compiling.

ERROR in node_modules/apexcharts/apexcharts.d.ts(526,16): error TS1122: A tuple type element list cannot be empty.

apexchart_error

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 19 (2 by maintainers)

Most upvoted comments

@sugihartolim ApexCharts is also exported as commonjs in the dist directory.

Can you please try

import ApexCharts from 'apexcharts/dist/apexcharts.common.js'

Thank you @ivelfan & @junedchhipa , that’s the final piece that finally made it work. As of angular 7 and apexcharts 3.2.2, to recap just in case anyone else needs it: (Note that ‘module: es2015’ WILL NOT work)

tsconfig.json: "compilerOptions" : { "module": "commonjs", "target": "es5", "esModuleInterop": true, "allowSyntheticDefaultImports": true }

// @ts-ignore 'import ApexCharts from ‘apexcharts’; ’

This is a temporary workaround until the export situation got resolved, i guess.

Hello, add to angular.json: "node_modules/apexcharts/dist/apexcharts.min.js" and import into the component this way: import 'apexcharts';

I use Angular 7 and I do this thing :

// @ts-ignore
import ApexCharts from 'apexcharts';

It’a a bit tricky but compiler let me in.

@osnoser1 Thank you for the additional solution. It works fine out of the box with angular 7 cli.

@junedchhipa The angular wrapper doesn’t work when i tried it this week. Didn’t have time to dig around yet. Maybe we shouldn’t recommend the thing on the front page until the kinks are worked out first? Thanks.