You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2020/04/27 09:54:04 UTC

[incubator-echarts] 01/04: ts: tweak types.

This is an automated email from the ASF dual-hosted git repository.

sushuang pushed a commit to branch next
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git

commit ed73906f11fadec7b2f0af37fb0972a84d30bf5d
Author: 100pah <su...@gmail.com>
AuthorDate: Sun Apr 26 17:09:17 2020 +0800

    ts: tweak types.
---
 extension-src/bmap/BMapCoordSys.ts             |  2 +-
 src/chart/helper/createClipPathFromCoordSys.ts |  7 ++++---
 src/chart/treemap/TreemapSeries.ts             |  4 +---
 src/coord/CoordinateSystem.ts                  |  2 ++
 src/data/DataDiffer.ts                         | 20 ++++++++++----------
 src/data/List.ts                               |  4 ++--
 src/model/Model.ts                             |  3 +++
 7 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/extension-src/bmap/BMapCoordSys.ts b/extension-src/bmap/BMapCoordSys.ts
index a80f044..77ca99e 100644
--- a/extension-src/bmap/BMapCoordSys.ts
+++ b/extension-src/bmap/BMapCoordSys.ts
@@ -89,7 +89,7 @@ BMapCoordSys.prototype.getRoamTransform = function () {
     return matrix.create();
 };
 
-BMapCoordSys.prototype.prepareCustoms = function (data) {
+BMapCoordSys.prototype.prepareCustoms = function () {
     const rect = this.getViewRect();
     return {
         coordSys: {
diff --git a/src/chart/helper/createClipPathFromCoordSys.ts b/src/chart/helper/createClipPathFromCoordSys.ts
index 2f2741b..d4b54c0 100644
--- a/src/chart/helper/createClipPathFromCoordSys.ts
+++ b/src/chart/helper/createClipPathFromCoordSys.ts
@@ -23,6 +23,7 @@ import SeriesModel from '../../model/Series';
 import { SeriesOption } from '../../util/types';
 import type Cartesian2D from '../../coord/cartesian/Cartesian2D';
 import type Polar from '../../coord/polar/Polar';
+import { CoordinateSystem } from '../../coord/CoordinateSystem';
 
 type SeriesModelWithLineWidth = SeriesModel<SeriesOption & {
     lineStyle?: { width?: number }
@@ -101,7 +102,7 @@ function createPolarClipPath(
 }
 
 function createClipPath(
-    coordSys: Polar | Cartesian2D,
+    coordSys: CoordinateSystem,
     hasAnimation: boolean,
     seriesModel: SeriesModelWithLineWidth
 ) {
@@ -109,10 +110,10 @@ function createClipPath(
         return null;
     }
     else if (coordSys.type === 'polar') {
-        return createPolarClipPath(coordSys, hasAnimation, seriesModel);
+        return createPolarClipPath(coordSys as Polar, hasAnimation, seriesModel);
     }
     else if (coordSys.type === 'cartesian2d') {
-        return createGridClipPath(coordSys, hasAnimation, seriesModel);
+        return createGridClipPath(coordSys as Cartesian2D, hasAnimation, seriesModel);
     }
     return null;
 }
diff --git a/src/chart/treemap/TreemapSeries.ts b/src/chart/treemap/TreemapSeries.ts
index 6d50700..2f6d860 100644
--- a/src/chart/treemap/TreemapSeries.ts
+++ b/src/chart/treemap/TreemapSeries.ts
@@ -200,9 +200,7 @@ class TreemapSeriesModel extends SeriesModel<TreemapSeriesOption> {
     static type = 'series.treemap';
     type = TreemapSeriesModel.type;
 
-    layoutMode = 'box';
-
-    dependencies = ['grid', 'polar'];
+    static layoutMode = 'box' as const;
 
     preventUsingHoverLayer = true;
 
diff --git a/src/coord/CoordinateSystem.ts b/src/coord/CoordinateSystem.ts
index 678cf21..84fd2f5 100644
--- a/src/coord/CoordinateSystem.ts
+++ b/src/coord/CoordinateSystem.ts
@@ -26,6 +26,7 @@ import { BoundingRect } from '../util/graphic';
 import { MatrixArray } from 'zrender/src/core/matrix';
 import ComponentModel from '../model/Component';
 import { RectLike } from 'zrender/src/core/BoundingRect';
+import { PrepareCustomInfo } from '../chart/custom';
 
 
 export interface CoordinateSystemCreator {
@@ -152,6 +153,7 @@ export interface CoordinateSystem {
     // But if other coordinate systems implement it, should follow this signature.
     getAxesByScale?: (scaleType: string) => Axis[];
 
+    prepareCustoms?: PrepareCustomInfo;
 }
 
 /**
diff --git a/src/data/DataDiffer.ts b/src/data/DataDiffer.ts
index 1da4288..993ead1 100644
--- a/src/data/DataDiffer.ts
+++ b/src/data/DataDiffer.ts
@@ -20,38 +20,38 @@
 import {ArrayLike} from 'zrender/src/core/types';
 
 // return key.
-export type DiffKeyGetter = (this: DataDiffer, value: any, index: number) => string;
+export type DiffKeyGetter = (this: DataDiffer, value: unknown, index: number) => string;
 export type DiffCallbackAdd = (newIndex: number) => void;
 export type DiffCallbackUpdate = (newIndex: number, oldIndex: number) => void;
 export type DiffCallbackRemove = (oldIndex: number) => void;
 
 type DataIndexMap = {[key: string]: number | number[]};
 
-function defaultKeyGetter<T>(item: T): T {
+function defaultKeyGetter(item: string): string {
     return item;
 }
 
-class DataDiffer {
+class DataDiffer<Ctx = unknown> {
 
-    private _old: ArrayLike<any>;
-    private _new: ArrayLike<any>;
+    private _old: ArrayLike<unknown>;
+    private _new: ArrayLike<unknown>;
     private _oldKeyGetter: DiffKeyGetter;
     private _newKeyGetter: DiffKeyGetter;
     private _add: DiffCallbackAdd;
     private _update: DiffCallbackUpdate;
     private _remove: DiffCallbackRemove;
 
-    readonly context: any;
+    readonly context: Ctx;
 
     /**
      * @param context Can be visited by this.context in callback.
      */
     constructor(
-        oldArr: ArrayLike<any>,
-        newArr: ArrayLike<any>,
+        oldArr: ArrayLike<unknown>,
+        newArr: ArrayLike<unknown>,
         oldKeyGetter?: DiffKeyGetter,
         newKeyGetter?: DiffKeyGetter,
-        context?: any
+        context?: Ctx
     ) {
         this._old = oldArr;
         this._new = newArr;
@@ -144,7 +144,7 @@ class DataDiffer {
     }
 
     private _initIndexMap(
-        arr: ArrayLike<any>,
+        arr: ArrayLike<unknown>,
         map: DataIndexMap,
         keyArr: string[],
         keyGetterName: '_oldKeyGetter' | '_newKeyGetter'
diff --git a/src/data/List.ts b/src/data/List.ts
index 20e8d77..34e621f 100644
--- a/src/data/List.ts
+++ b/src/data/List.ts
@@ -1603,10 +1603,10 @@ class List<
         return new DataDiffer(
             otherList ? otherList.getIndices() : [],
             this.getIndices(),
-            function (idx) {
+            function (idx: number) {
                 return getId(otherList, idx);
             },
-            function (idx) {
+            function (idx: number) {
                 return getId(thisList, idx);
             }
         );
diff --git a/src/model/Model.ts b/src/model/Model.ts
index bd3e282..0967877 100644
--- a/src/model/Model.ts
+++ b/src/model/Model.ts
@@ -147,6 +147,9 @@ class Model<Opt extends ModelOption = ModelOption> {    // TODO: TYPE use unkown
     getModel<R extends keyof Opt, S extends keyof Opt[R]>(
         path: readonly [R, S], parentModel?: Model
     ): Model<Opt[R][S]>;
+    getModel<Ra extends keyof Opt, Rb extends keyof Opt, S extends keyof Opt[Rb]>(
+        path: readonly [Ra] | readonly [Rb, S], parentModel?: Model
+    ): Model<Opt[Ra]> | Model<Opt[Rb][S]>;
     getModel<R extends keyof Opt, S extends keyof Opt[R], T extends keyof Opt[R][S]>(
         path: readonly [R, S, T], parentModel?: Model
     ): Model<Opt[R][S][T]>;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org