提交 ed73906f 编写于 作者: 1 100pah

ts: tweak types.

上级 ea9ad4a8
......@@ -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: {
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
}
/**
......
......@@ -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'
......
......@@ -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);
}
);
......
......@@ -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]>;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册