toomuchdesign/react-minimal-pie-chart

Typescript error when importing

romeerez opened this issue · 3 comments

Bit easier to say it without issue template:

I used create-react-app with --template typescript, it installs typescript v3.7.3, and using this version I got:

import {PieChart} from "react-minimal-pie-chart"

Is causing this error:

TypeScript error in .../node_modules/react-minimal-pie-chart/types/Chart/Chart.d.ts(1,13):
'=' expected.  TS1005

  > 1 | import type { CSSProperties, FocusEvent, KeyboardEvent, MouseEvent, ReactNode } from 'react';
      |             ^
    2 | import type { Data, EventHandler, LabelRenderFunction } from '../commonTypes';
    3 | declare type Props = {
    4 |     animate?: boolean;

Fixed it by changing typescript version to 3.8.3, in fact it's not a bad thing to not support older version, but it was confusing

It seems to be caused by the import type syntax, introduced around version 3.8.

I didn't expect Typescript to preserve it after type definition generation but... you never know with TS :)

If there's a way to export type definitions without import type syntax and make it compatible with previous TS version I'd totally consider it.

Docs updated with info about minimum supported Typescript version (>= 3.8). Thank you @Romaboy

You can use its UMD https://unpkg.com/react-minimal-pie-chart/dist/index.js if you typescript version is less than 3.8.