Skip to content

Commit

Permalink
fix(types): Fix wrong type definition
Browse files Browse the repository at this point in the history
Fix wrong type definition for
- .load(), .zoom() callback option
- make preserveAspectRatio option from .export() as optional
- specify Plugin interface context

Fix #2316
  • Loading branch information
netil committed Sep 15, 2021
1 parent 4fce8cb commit 5f7779b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions types/chart.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export interface Chart {
* Zoom by giving x domain.
* @param domain If domain is given, the chart will be zoomed to the given domain. If no argument is given, the current zoomed domain will be returned.
*/
(domain?: number[]): number[];
(domain?: Array<Date|number>): Array<Date|number>;

/**
* Enable and disable zooming.
Expand Down Expand Up @@ -363,7 +363,7 @@ export interface Chart {
type?: string;
types?: { [key: string]: string };
unload?: boolean | ArrayOrString;
done?: () => any;
done?: (this: Chart) => void;
}): void;

/**
Expand All @@ -378,7 +378,7 @@ export interface Chart {
* - If you call load API soon after/before unload, unload param of load should be used. Otherwise chart will not be rendered properly because of cancel of animation.
* - done will be called after data loaded, but it's not after rendering. It's because rendering will finish after some transition and there is some time lag between loading and rendering.
*/
unload(this: Chart, targetIds?: TargetIds, done?: () => any): any;
unload(this: Chart, targetIds?: TargetIds, done?: (this: Chart) => void): void;

/**
* Flow data to the chart. By this API, you can append new data points to the chart.
Expand Down Expand Up @@ -409,7 +409,7 @@ export interface Chart {
to?: any;
length?: number;
duration?: number;
done?(this: Chart): any;
done?(this: Chart): void;
}): void;

/**
Expand Down Expand Up @@ -509,9 +509,9 @@ export interface Chart {
export(this: Chart, option?: {
width?: number;
height?: number;
mimeType: string;
preserveAspectRatio: boolean;
}, callback?: (dataUrl: string) => string): string;
mimeType?: string;
preserveAspectRatio?: boolean;
}, callback?: (this: Chart, dataUrl: string) => void): string;

/**
* Get or set single config option value.
Expand Down
10 changes: 5 additions & 5 deletions types/plugin/plugin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ export interface Plugin {
/**
* Lifecycle hook for 'beforeInit' phase.
*/
$beforeInit?: () => void;
$beforeInit?: (this: Plugin) => void;

/**
* Lifecycle hook for 'init' phase.
*/
$init?: () => void;
$init?: (this: Plugin) => void;

/**
* Lifecycle hook for 'afterInit' phase.
*/
$afterInit?: () => void;
$afterInit?: (this: Plugin) => void;

/**
* Lifecycle hook for 'redraw' phase.
*/
$redraw?: () => void;
$redraw?: (this: Plugin) => void;

/**
* Lifecycle hook for 'willDestroy' phase.
*/
$willDestroy?: () => void;
$willDestroy?: (this: Plugin) => void;
}

0 comments on commit 5f7779b

Please sign in to comment.