Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose TParsedData at top level of types #8499

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions types/index.esm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,14 @@ export interface ActiveElement extends ActiveDataPoint {
export declare class Chart<
TType extends ChartType = ChartType,
TData extends unknown[] = DefaultDataPoint<TType>,
TLabel = unknown
TLabel = unknown,
TParsedData extends unknown = ParsedDataType<TType>
> {
readonly platform: BasePlatform;
readonly id: string;
readonly canvas: HTMLCanvasElement;
readonly ctx: CanvasRenderingContext2D;
readonly config: ChartConfiguration<TType, TData, TLabel>
readonly config: ChartConfiguration<TType, TData, TLabel, TParsedData>
readonly width: number;
readonly height: number;
readonly aspectRatio: number;
Expand All @@ -462,7 +463,7 @@ export declare class Chart<
data: ChartData<TType, TData, TLabel>;
options: ChartOptions<TType>;

constructor(item: ChartItem, config: ChartConfiguration<TType, TData, TLabel>);
constructor(item: ChartItem, config: ChartConfiguration<TType, TData, TLabel, TParsedData>);

clear(): this;
stop(): this;
Expand Down
18 changes: 18 additions & 0 deletions types/tests/test_specify_types_chart_constructor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Chart } from '../index.esm';

const chart = new Chart<'scatter', number[], string>('id', {
type: 'scatter',
data: {
labels: [],
datasets: []
},
options: {},
});

interface Context {
chart: Chart<'scatter'|'bar', unknown[], unknown, unknown>;
}

const ctx: Context = {
chart: chart
};