Open
Description
A current frustration with types right now is that we can't provide context aware types for the users due to how our types are declared.
This change could provide valuable IDE information to our final users in how the components can be used.
Example
import * as React from 'react';
type Prop1 = {
height: number;
width: number;
data: number[];
responsive?: never;
};
type Prop2 = {
responsive: true;
data: string[];
};
type Props = Prop1 | Prop2;
const Component = (props: Props) => {
return null;
};
export default function Page() {
return (
<>
<Component responsive data={['aaa']} />
<Component height={1} width={2} data={[2]} />
{/* Unexpected prop value */}
<Component responsive={false} />
{/* Data should be string when used with responsive */}
<Component responsive data={[1]} />
</>
);
}
Possible implementations
- All charts:
dataset
vsno dataset
- The
dataset
mode could require that thedataKey
is set in the series data
mode would forbiddataKey
and requiredata
- The
Search keywords: