Skip to content

Commit

Permalink
feat(type): export EChartsInitOpts and more types for echarts/core (
Browse files Browse the repository at this point in the history
#19103)

* feat: add missing types

* revert the option export
  • Loading branch information
Dale Nguyen committed Sep 12, 2023
1 parent a06dd62 commit de074fb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/core/echarts.ts
Expand Up @@ -318,7 +318,7 @@ type ECEventDefinition = {
// TODO: Use ECActionEvent
[key: string]: (...args: unknown[]) => void | boolean
};
type EChartsInitOpts = {
export type EChartsInitOpts = {
locale?: string | LocaleOption,
renderer?: RendererType,
devicePixelRatio?: number,
Expand Down
43 changes: 25 additions & 18 deletions src/export/core.ts
Expand Up @@ -25,16 +25,23 @@ import { use } from '../extension';

// Import label layout by default.
// TODO will be treeshaked.
import {installLabelLayout} from '../label/installLabelLayout';
import { installLabelLayout } from '../label/installLabelLayout';
use(installLabelLayout);


// Export necessary types
export {ZRColor as Color, Payload, ECElementEvent} from '../util/types';
export {LinearGradientObject} from 'zrender/src/graphic/LinearGradient';
export {RadialGradientObject} from 'zrender/src/graphic/RadialGradient';
export {PatternObject, ImagePatternObject, SVGPatternObject} from 'zrender/src/graphic/Pattern';
export {ElementEvent} from 'zrender/src/Element';
export {
ZRColor as Color,
Payload,
ECElementEvent,
HighlightPayload,
DownplayPayload,
SelectChangedPayload
} from '../util/types';
export { LinearGradientObject } from 'zrender/src/graphic/LinearGradient';
export { RadialGradientObject } from 'zrender/src/graphic/RadialGradient';
export { PatternObject, ImagePatternObject, SVGPatternObject } from 'zrender/src/graphic/Pattern';
export { ElementEvent } from 'zrender/src/Element';

// ComposeOption
import type { ComponentOption, ECBasicOption as EChartsCoreOption } from '../util/types';
Expand All @@ -45,9 +52,9 @@ import type { AngleAxisOption, RadiusAxisOption } from '../coord/polar/AxisModel
import type { ParallelAxisOption } from '../coord/parallel/AxisModel';


export {EChartsType as ECharts} from '../core/echarts';
export { EChartsType as ECharts } from '../core/echarts';

export {EChartsCoreOption};
export { EChartsCoreOption };

// type SeriesSubComponentsTypes = 'markPoint' | 'markLine' | 'markArea' | 'tooltip';
// type InjectSeriesSubComponents<OptionUnion extends ComponentOption, Injected> =
Expand Down Expand Up @@ -92,16 +99,16 @@ type ComposeUnitOption<OptionUnion extends ComponentOption> =
Omit<EChartsCoreOption, 'baseOption' | 'options'> & {
[key in GetMainType<OptionUnion>]?: Arrayable<
ExtractComponentOption<OptionUnion, key>
// TODO: It will make error log too complex.
// So this more strict type checking will not be used currently to make sure the error msg is friendly.
//
// Inject markPoint, markLine, markArea, tooltip in series.
// ExtractComponentOption<
// InjectSeriesSubComponents<
// OptionUnion, GetSeriesInjectedSubOption<GetMainType<OptionUnion>, OptionUnion>
// >,
// key
// >
// TODO: It will make error log too complex.
// So this more strict type checking will not be used currently to make sure the error msg is friendly.
//
// Inject markPoint, markLine, markArea, tooltip in series.
// ExtractComponentOption<
// InjectSeriesSubComponents<
// OptionUnion, GetSeriesInjectedSubOption<GetMainType<OptionUnion>, OptionUnion>
// >,
// key
// >
>
} & GetDependencies<GetMainType<OptionUnion>>;

Expand Down

0 comments on commit de074fb

Please sign in to comment.