-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
What is the current behavior?
Receiving build errors such as:
src/lib/components/bar/bar.tsx(22,14): error TS4023: Exported variable 'Bar' has or is using name 'BarEvents' from external module "/home/runner/_work/pb-frontend/pb-frontend/node_modules/.pnpm/recharts@3.1.2_@types+react@18.3.1_react-dom@18.3.1_react@18.3.1__react-is@18.3.1_react@18.3.1_redux@5.0.1/node_modules/recharts/types/cartesian/Bar" but cannot be named.
src/lib/components/line/line.tsx(11,14): error TS4023: Exported variable 'Line' has or is using name 'CurveProps' from external module "/home/runner/_work/pb-frontend/pb-frontend/node_modules/.pnpm/recharts@3.1.2_@types+react@18.3.1_react-dom@18.3.1_react@18.3.1__react-is@18.3.1_react@18.3.1_redux@5.0.1/node_modules/recharts/types/shape/Curve" but cannot be named.
src/lib/components/line/line.tsx(11,14): error TS4023: Exported variable 'Line' has or is using name 'LineProps' from external module "/home/runner/_work/pb-frontend/pb-frontend/node_modules/.pnpm/recharts@3.1.2_@types+react@18.3.1_react-dom@18.3.1_react@18.3.1__react-is@18.3.1_react@18.3.1_redux@5.0.1/node_modules/recharts/types/cartesian/Line" but cannot be named.
It seems like types BarEvents, CurveProps should not be internal types. This started happening when my project was set to use project references by enabling composite: true,declaration: true and incremental: true.
One of the files looked like this:
import React, { forwardRef } from 'react';
import type { LineProps } from 'recharts';
import { Line as RechartsLine } from 'recharts';
const LINE_CHART_DEFAULT_PROPS = {
type: 'linear' as const,
strokeWidth: 2,
dot: false,
};
export const Line = forwardRef<HTMLElement, LineProps>((props, _ref) => (
<RechartsLine {...LINE_CHART_DEFAULT_PROPS} {...props} />
));
Line.displayName = 'Line';
Setting export interface LineProps in types/cartesian/Line.d.ts and export interface CurveProps in types/shape/Curve.d.ts helps the issue.
For the other file, changing import from:
import type { BarProps, LabelProps } from 'recharts';
to
import type { BarProps } from 'recharts/types/cartesian/Bar';
seems to do the trick.
What is the expected behavior?
Not get build errors
Please provide a demo of the problem in a sandbox
Clone this repo: https://github.com/productboardlabs/recharts-build-issue-bug
Run pnpm install and then pnpm build
Please try to keep the demo as small as possible while still showing the problem.
Which versions of Recharts, and which browser / OS are affected by this issue? Did this work in previous versions of Recharts?
recharts@3.1.2 and typescript@5.8.3