You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2020/12/14 06:18:18 UTC

[incubator-echarts] branch treeshakable-exports updated: chore: upgrade ts version to 4.1

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

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


The following commit(s) were added to refs/heads/treeshakable-exports by this push:
     new ce05d25  chore: upgrade ts version to 4.1
ce05d25 is described below

commit ce05d256d7b248e9a3ce88fc9708f384b04b2c97
Author: pissang <bm...@gmail.com>
AuthorDate: Mon Dec 14 14:17:19 2020 +0800

    chore: upgrade ts version to 4.1
---
 .eslintrc-common.yaml                     |  5 ++-
 build/config.js                           |  2 +-
 build/pre-publish.js                      | 62 +++++++++++++++++--------------
 build/template/charts.d.ts                |  5 +--
 build/template/components.d.ts            |  5 +--
 build/template/core.d.ts                  |  2 +-
 build/template/{core.d.ts => option.d.ts} |  2 +-
 build/template/renderers.d.ts             |  5 +--
 index.d.ts                                | 11 +-----
 package.json                              | 28 +++++++-------
 src/chart/bar/BarSeries.ts                |  1 -
 src/component/graphic/install.ts          |  2 +-
 src/component/marker/MarkAreaView.ts      |  6 ++-
 src/component/marker/MarkLineView.ts      |  6 ++-
 src/coord/radar/RadarModel.ts             |  2 +-
 src/data/Graph.ts                         | 22 +++++++++--
 src/echarts.ts                            | 10 ++---
 src/export/core.ts                        |  4 +-
 src/extension.ts                          |  5 ++-
 src/model/Model.ts                        | 17 +++++----
 test/types/importPartial.ts               | 20 ++++++----
 21 files changed, 124 insertions(+), 98 deletions(-)

diff --git a/.eslintrc-common.yaml b/.eslintrc-common.yaml
index e502508..d0fe9be 100644
--- a/.eslintrc-common.yaml
+++ b/.eslintrc-common.yaml
@@ -28,6 +28,7 @@
 # ```
 # Note that it should be "workingDirectories" rather than "WorkingDirectories".
 
+root: true
 rules:
     # Check the rules in: node_modules/@typescript-eslint/eslint-plugin/README.md
     no-console:
@@ -80,7 +81,6 @@ rules:
     no-octal: 2
     no-octal-escape: 2
     no-proto: 2
-    no-redeclare: 2
     no-self-compare: 2
     no-unneeded-ternary: 2
     no-with: 2
@@ -215,4 +215,5 @@ rules:
         - 1
         -
             vars: "local"
-            args: "none"
\ No newline at end of file
+            args: "none"
+    "@typescript-eslint/no-redeclare": 2
\ No newline at end of file
diff --git a/build/config.js b/build/config.js
index 5c9d8fe..b19ecbc 100644
--- a/build/config.js
+++ b/build/config.js
@@ -18,7 +18,7 @@
 */
 
 const assert = require('assert');
-const nodeResolvePlugin = require('rollup-plugin-node-resolve');
+const nodeResolvePlugin = require('@rollup/plugin-node-resolve').default;
 const nodePath = require('path');
 const ecDir = nodePath.resolve(__dirname, '..');
 const typescriptPlugin = require('rollup-plugin-typescript2');
diff --git a/build/pre-publish.js b/build/pre-publish.js
index 193177e..bc993bb 100644
--- a/build/pre-publish.js
+++ b/build/pre-publish.js
@@ -37,9 +37,9 @@ const ts = require('typescript');
 const globby = require('globby');
 const transformDEVUtil = require('./transform-dev');
 const preamble = require('./preamble');
-// NOTE: v1.4.2 is the latest version that supports ts 3.8.3
-const dts = require('rollup-plugin-dts').default;
+const dts = require('@lang/rollup-plugin-dts').default;
 const rollup = require('rollup');
+const { consoleLogger } = require('@definitelytyped/utils');
 
 const ecDir = nodePath.resolve(__dirname, '..');
 const tmpDir = nodePath.resolve(ecDir, 'pre-publish-tmp');
@@ -400,8 +400,18 @@ async function readFilePaths({patterns, cwd}) {
 }
 
 async function bundleDTS() {
+
+    const parts = [
+        'core', 'charts', 'components', 'renderers', 'option'
+    ];
+    const inputs = {};
+    parts.forEach(partName => {
+        inputs[partName] = nodePath.resolve(__dirname, `../types/src/export/${partName}.d.ts`)
+    });
+
+    const outDir = nodePath.resolve(__dirname, '../types/dist');
     const bundle = await rollup.rollup({
-        input: nodePath.resolve(__dirname, '../index.d.ts'),
+        input: inputs,
         onwarn(warning, rollupWarn) {
             // Not warn circular dependency
             if (warning.code !== 'CIRCULAR_DEPENDENCY') {
@@ -411,19 +421,27 @@ async function bundleDTS() {
         plugins: [
             dts({
                 respectExternal: true
-            })
+            }),
+            {
+                generateBundle(options, bundle) {
+                    for (let chunk of Object.values(bundle)) {
+                        chunk.code = `
+type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
+${chunk.code}`
+                    }
+                }
+            }
         ]
     });
-    const bundleFile = nodePath.resolve(__dirname, '../types/dist/echarts.d.ts');
+    let idx = 1;
     await bundle.write({
-        file: bundleFile
+        dir: outDir,
+        chunkFileNames: (chunkInfo) => {
+            const fileName = `common${idx > 1 ? idx : ''}.d.ts`;
+            idx++;
+            return fileName;
+        }
     });
-    // To support ts 3.4
-    const extra = `
-type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
-`
-    const code = extra + fs.readFileSync(bundleFile, 'utf-8');
-    fs.writeFileSync(bundleFile, code, 'utf-8');
 }
 
 function readTSConfig() {
@@ -437,22 +455,12 @@ function readTSConfig() {
 
 function generateEntries() {
     ['charts', 'components', 'renderers', 'core'].forEach(entryName => {
-        const jsCode = fs.readFileSync(nodePath.join(__dirname, `template/${entryName}.js`), 'utf-8');
-        let dtsCode = fs.readFileSync(nodePath.join(__dirname, `/template/${entryName}.d.ts`), 'utf-8');
-
-        fs.writeFileSync(nodePath.join(__dirname, `../${entryName}.js`), jsCode, 'utf-8');
-
-        if (dtsCode.indexOf('{{body}}') >= 0) {
-            const exportModulesCode = [];
-            const modules = require(`../lib/export/${entryName}`);
-            for (let key in modules) {
-                if (modules.hasOwnProperty(key) && !key.startsWith('_')) {
-                    exportModulesCode.push(`export declare const ${key}: EChartsExtensionInstaller;`);
-                }
-            }
-
-            dtsCode = dtsCode.replace('{{body}}', exportModulesCode.join('\n'));
+        if (entryName !== 'option') {
+            const jsCode = fs.readFileSync(nodePath.join(__dirname, `template/${entryName}.js`), 'utf-8');
+            fs.writeFileSync(nodePath.join(__dirname, `../${entryName}.js`), jsCode, 'utf-8');
         }
+
+        const dtsCode = fs.readFileSync(nodePath.join(__dirname, `/template/${entryName}.d.ts`), 'utf-8');
         fs.writeFileSync(nodePath.join(__dirname, `../${entryName}.d.ts`), dtsCode, 'utf-8');
     });
 }
diff --git a/build/template/charts.d.ts b/build/template/charts.d.ts
index ed011db..5c9edfc 100644
--- a/build/template/charts.d.ts
+++ b/build/template/charts.d.ts
@@ -17,7 +17,4 @@
 * under the License.
 */
 
-// Use an empty flag function to avoid import unecessary types.
-type EChartsExtensionInstaller = (registers: any) => void;
-
-{{body}}
\ No newline at end of file
+export * from './types/dist/charts';
\ No newline at end of file
diff --git a/build/template/components.d.ts b/build/template/components.d.ts
index ed011db..5bb38be 100644
--- a/build/template/components.d.ts
+++ b/build/template/components.d.ts
@@ -17,7 +17,4 @@
 * under the License.
 */
 
-// Use an empty flag function to avoid import unecessary types.
-type EChartsExtensionInstaller = (registers: any) => void;
-
-{{body}}
\ No newline at end of file
+export * from './types/dist/components';
\ No newline at end of file
diff --git a/build/template/core.d.ts b/build/template/core.d.ts
index 3e7a508..c3f461a 100644
--- a/build/template/core.d.ts
+++ b/build/template/core.d.ts
@@ -17,4 +17,4 @@
 * under the License.
 */
 
-export * from './types/src/export/core';
\ No newline at end of file
+export * from './types/dist/core';
\ No newline at end of file
diff --git a/build/template/core.d.ts b/build/template/option.d.ts
similarity index 95%
copy from build/template/core.d.ts
copy to build/template/option.d.ts
index 3e7a508..7ebeaae 100644
--- a/build/template/core.d.ts
+++ b/build/template/option.d.ts
@@ -17,4 +17,4 @@
 * under the License.
 */
 
-export * from './types/src/export/core';
\ No newline at end of file
+export * from './types/dist/option';
\ No newline at end of file
diff --git a/build/template/renderers.d.ts b/build/template/renderers.d.ts
index ed011db..2fb46e9 100644
--- a/build/template/renderers.d.ts
+++ b/build/template/renderers.d.ts
@@ -17,7 +17,4 @@
 * under the License.
 */
 
-// Use an empty flag function to avoid import unecessary types.
-type EChartsExtensionInstaller = (registers: any) => void;
-
-{{body}}
\ No newline at end of file
+export * from './types/dist/renderers';
\ No newline at end of file
diff --git a/index.d.ts b/index.d.ts
index 36c5523..012239a 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -21,13 +21,6 @@
 /// NOTE: types folder is generated by `npm run prepublish` command ///
 /// Make sure run it before edit this file.                         ///
 ///////////////////////////////////////////////////////////////////////
-// Restrict exports
-export {
-    init, connect, disConnect, dispose, getInstanceByDom, getInstanceById,
-    registerMap, registerLocale, getMap, registerTheme,
-    graphic, util, format, EChartsType as ECharts
-} from './types/src/export/core';
 
-export {useSimple as use} from './types/src/extension';
-
-export * from './types/src/export/option';
\ No newline at end of file
+export * from './types/dist/core';
+export * from './types/dist/option';
\ No newline at end of file
diff --git a/package.json b/package.json
index 09a74ed..35660cf 100644
--- a/package.json
+++ b/package.json
@@ -10,7 +10,7 @@
   "main": "index.js",
   "module": "index.esm.js",
   "jsdelivr": "dist/echarts.min.js",
-  "types": "types/dist/echarts.d.ts",
+  "types": "index.d.ts",
   "homepage": "http://echarts.apache.org",
   "repository": {
     "type": "git",
@@ -34,8 +34,8 @@
     "help": "node build/build.js --help",
     "test:visual": "node test/runTest/server.js",
     "test:visual:report": "node test/runTest/genReport.js",
-    "test": "jest --config test/ut/jest.config.js",
-    "test:single": "jest --config test/ut/jest.config.js --coverage=false -t",
+    "test": "npx jest --config test/ut/jest.config.js",
+    "test:single": "npx jest --config test/ut/jest.config.js --coverage=false -t",
     "test:dts": "node build/testDts.js",
     "mktest": "node test/build/mktest.js",
     "mktest:help": "node test/build/mktest.js -h",
@@ -44,23 +44,28 @@
     "lint:dist": "echo 'It might take a while. Please wait ...' && ./node_modules/.bin/jshint --config .jshintrc-dist dist/echarts.js"
   },
   "dependencies": {
-    "tslib": "1.10.0",
+    "tslib": "2.0.3",
     "zrender": "5.0.1"
   },
   "devDependencies": {
+    "@babel/code-frame": "7.10.4",
     "@babel/core": "7.3.4",
-    "@babel/types": "^7.10.5",
+    "@babel/types": "7.10.5",
+    "@definitelytyped/typescript-versions": "0.0.64",
+    "@definitelytyped/utils": "0.0.64",
+    "@lang/rollup-plugin-dts": "2.0.2",
     "@microsoft/api-extractor": "7.7.2",
+    "@rollup/plugin-node-resolve": "11.0.0",
     "@types/jest": "^26.0.14",
-    "@typescript-eslint/eslint-plugin": "^2.15.0",
-    "@typescript-eslint/parser": "^2.18.0",
+    "@typescript-eslint/eslint-plugin": "^4.9.1",
+    "@typescript-eslint/parser": "^4.9.1",
     "canvas": "^2.6.0",
     "chalk": "^3.0.0",
     "chokidar": "^3.4.0",
     "commander": "2.11.0",
     "dtslint": "^4.0.5",
     "esbuild": "^0.4.1",
-    "eslint": "6.3.0",
+    "eslint": "^7.15.0",
     "fs-extra": "0.26.7",
     "glob": "7.0.0",
     "globby": "11.0.0",
@@ -72,10 +77,7 @@
     "open": "6.4.0",
     "pixelmatch": "5.0.2",
     "pngjs": "3.4.0",
-    "rollup": "1.28.0",
-    "rollup-plugin-commonjs": "8.4.1",
-    "rollup-plugin-dts": "1.4.2",
-    "rollup-plugin-node-resolve": "3.0.0",
+    "rollup": "2.34.2",
     "rollup-plugin-typescript2": "0.25.3",
     "seedrandom": "3.0.3",
     "semver": "6.3.0",
@@ -84,7 +86,7 @@
     "socket.io": "2.2.0",
     "terser": "^5.3.8",
     "ts-jest": "^26.4.3",
-    "typescript": "3.8.3",
+    "typescript": "^4.1.2",
     "uglify-js": "^3.10.0"
   }
 }
diff --git a/src/chart/bar/BarSeries.ts b/src/chart/bar/BarSeries.ts
index bfa4360..0cb5399 100644
--- a/src/chart/bar/BarSeries.ts
+++ b/src/chart/bar/BarSeries.ts
@@ -18,7 +18,6 @@
 */
 
 import BaseBarSeriesModel, {BaseBarSeriesOption} from './BaseBarSeries';
-import SeriesModel from '../../model/Series';
 import {
     ItemStyleOption,
     OptionDataValue,
diff --git a/src/component/graphic/install.ts b/src/component/graphic/install.ts
index a99d9ca..e15b5ca 100644
--- a/src/component/graphic/install.ts
+++ b/src/component/graphic/install.ts
@@ -459,7 +459,7 @@ class GraphicComponentView extends ComponentView {
             if (elOptionStyle
                 && isEC4CompatibleStyle(elOptionStyle, elType, !!textConfig, !!textContentOption)
             ) {
-                const convertResult = convertFromEC4CompatibleStyle(elOptionStyle, elType, true);
+                const convertResult = convertFromEC4CompatibleStyle(elOptionStyle, elType, true) as GraphicComponentZRPathOption;
                 if (!textConfig && convertResult.textConfig) {
                     textConfig = (elOption as GraphicComponentZRPathOption).textConfig = convertResult.textConfig;
                 }
diff --git a/src/component/marker/MarkAreaView.ts b/src/component/marker/MarkAreaView.ts
index c719677..42b7811 100644
--- a/src/component/marker/MarkAreaView.ts
+++ b/src/component/marker/MarkAreaView.ts
@@ -40,6 +40,7 @@ import { makeInner } from '../../util/model';
 import { getVisualFromData } from '../../visual/helper';
 import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle';
 import { getECData } from '../../util/innerStore';
+import Axis2D from '../../coord/cartesian/Axis2D';
 
 interface MarkAreaDrawGroup {
     group: graphic.Group
@@ -167,8 +168,9 @@ function getSingleMarkerEndPoint(
             point = coordSys.dataToPoint(pt, true);
         }
         if (isCoordinateSystemType<Cartesian2D>(coordSys, 'cartesian2d')) {
-            const xAxis = coordSys.getAxis('x');
-            const yAxis = coordSys.getAxis('y');
+            // TODO: TYPE ts@4.1 may still infer it as Axis instead of Axis2D. Not sure if it's a bug
+            const xAxis = coordSys.getAxis('x') as Axis2D;
+            const yAxis = coordSys.getAxis('y') as Axis2D;
             const x = data.get(dims[0], idx) as number;
             const y = data.get(dims[1], idx) as number;
             if (isInifinity(x)) {
diff --git a/src/component/marker/MarkLineView.ts b/src/component/marker/MarkLineView.ts
index 1a53633..7fc9553 100644
--- a/src/component/marker/MarkLineView.ts
+++ b/src/component/marker/MarkLineView.ts
@@ -48,6 +48,7 @@ import {
 import { makeInner } from '../../util/model';
 import { LineDataVisual } from '../../visual/commonVisualTypes';
 import { getVisualFromData } from '../../visual/helper';
+import Axis2D from '../../coord/cartesian/Axis2D';
 
 // Item option for configuring line and each end of symbol.
 // Line option. be merged from configuration of two ends.
@@ -233,8 +234,9 @@ function updateSingleMarkerEndLayout(
         //    }]
         //  }
         if (isCoordinateSystemType<Cartesian2D>(coordSys, 'cartesian2d')) {
-            const xAxis = coordSys.getAxis('x');
-            const yAxis = coordSys.getAxis('y');
+            // TODO: TYPE ts@4.1 may still infer it as Axis instead of Axis2D. Not sure if it's a bug
+            const xAxis = coordSys.getAxis('x') as Axis2D;
+            const yAxis = coordSys.getAxis('y') as Axis2D;
             const dims = coordSys.dimensions;
             if (isInifinity(data.get(dims[0], idx))) {
                 point[0] = xAxis.toGlobalCoord(xAxis.getExtent()[isFrom ? 0 : 1]);
diff --git a/src/coord/radar/RadarModel.ts b/src/coord/radar/RadarModel.ts
index dd1062b..6eecb95 100644
--- a/src/coord/radar/RadarModel.ts
+++ b/src/coord/radar/RadarModel.ts
@@ -138,7 +138,7 @@ class RadarModel extends ComponentModel<RadarOption> implements CoordinateSystem
                 // min: 0,
                 nameTextStyle: iNameTextStyle,
                 triggerEvent: triggerEvent
-            }, false);
+            } as InnerIndicatorAxisOption, false);
             if (!showName) {
                 innerIndicatorOpt.name = '';
             }
diff --git a/src/data/Graph.ts b/src/data/Graph.ts
index e71dc75..75ec38f 100644
--- a/src/data/Graph.ts
+++ b/src/data/Graph.ts
@@ -432,10 +432,26 @@ class GraphEdge {
 
 type GetDataName<Host> = Host extends GraphEdge ? 'edgeData' : 'data';
 
+interface GraphDataProxyMixin {
+    getValue(dimension?: DimensionLoose): ParsedValue;
+    // TODO: TYPE stricter type.
+    setVisual(key: string | Dictionary<any>, value?: any): void;
+
+    getVisual(key: string): any,
+
+    setLayout(layout: any, merge?: boolean): void;
+
+    getLayout(): any
+
+    getGraphicEl(): Element
+
+    getRawIndex(): number
+}
+
 function createGraphDataProxyMixin<Host extends GraphEdge | GraphNode>(
     hostName: 'hostGraph',
     dataName: GetDataName<Host>
-) {
+): GraphDataProxyMixin {
     return {
         /**
          * @param Default 'value'. can be 'a', 'b', 'c', 'd', 'e'.
@@ -474,8 +490,8 @@ function createGraphDataProxyMixin<Host extends GraphEdge | GraphNode>(
 };
 
 
-interface GraphEdge extends ReturnType<typeof createGraphDataProxyMixin> {};
-interface GraphNode extends ReturnType<typeof createGraphDataProxyMixin> {};
+interface GraphEdge extends GraphDataProxyMixin {};
+interface GraphNode extends GraphDataProxyMixin {};
 
 zrUtil.mixin(GraphNode, createGraphDataProxyMixin('hostGraph', 'data'));
 zrUtil.mixin(GraphEdge, createGraphDataProxyMixin('hostGraph', 'edgeData'));
diff --git a/src/echarts.ts b/src/echarts.ts
index d58a776..dcddf89 100644
--- a/src/echarts.ts
+++ b/src/echarts.ts
@@ -546,9 +546,9 @@ class ECharts extends Eventful {
      * @param opts.replaceMerge Default undefined.
      */
     // Expose to user full option.
-    setOption(option: EChartsOption, notMerge?: boolean, lazyUpdate?: boolean): void;
-    setOption(option: EChartsOption, opts?: SetOptionOpts): void;
-    setOption(option: EChartsOption, notMerge?: boolean | SetOptionOpts, lazyUpdate?: boolean): void {
+    setOption<Opt extends ECBasicOption = EChartsOption>(option: Opt, notMerge?: boolean, lazyUpdate?: boolean): void;
+    setOption<Opt extends ECBasicOption = EChartsOption>(option: Opt, opts?: SetOptionOpts): void;
+    setOption<Opt extends ECBasicOption = EChartsOption>(option: Opt, notMerge?: boolean | SetOptionOpts, lazyUpdate?: boolean): void {
         if (__DEV__) {
             assert(!this[IN_MAIN_PROCESS_KEY], '`setOption` should not be called during main process.');
         }
@@ -619,8 +619,8 @@ class ECharts extends Eventful {
         return this._model;
     }
 
-    getOption(): EChartsOption {
-        return this._model && this._model.getOption() as EChartsOption;
+    getOption(): ECBasicOption {
+        return this._model && this._model.getOption() as ECBasicOption;
     }
 
     getWidth(): number {
diff --git a/src/export/core.ts b/src/export/core.ts
index 8b8595c..a7991c2 100644
--- a/src/export/core.ts
+++ b/src/export/core.ts
@@ -22,11 +22,13 @@ import { ComponentOption, ECBasicOption as EChartsCoreOption, SeriesOption } fro
 export * from '../echarts';
 export * from './api';
 
+export {EChartsType as ECharts} from '../echarts';
+
 export {EChartsCoreOption};
 
 type ComposeUnitOption<ComponentsOptionUnion extends ComponentOption, SeriesOptionUnion extends SeriesOption> =
     EChartsCoreOption & {
-        [key in ComponentsOptionUnion['mainType']]: ComponentsOptionUnion | ComponentsOptionUnion[];
+        [key in ComponentsOptionUnion['mainType']]?: ComponentsOptionUnion | ComponentsOptionUnion[];
     } & {
         series?: SeriesOptionUnion | SeriesOptionUnion[]
     };
diff --git a/src/extension.ts b/src/extension.ts
index ae43c78..2a009c7 100644
--- a/src/extension.ts
+++ b/src/extension.ts
@@ -108,5 +108,6 @@ export function use(
 }
 
 // A simpler use type for exporting to reduce exported inner modules.
-type SimpleEChartsExtensionType = Function | { install: Function };
-export declare function useSimple(ext: SimpleEChartsExtensionType | (SimpleEChartsExtensionType)[]): void;
\ No newline at end of file
+export type EChartsExtensionInstallerSimple = (registers: any) => void;
+type SimpleEChartsExtensionType = EChartsExtensionInstallerSimple | { install: EChartsExtensionInstallerSimple };
+export declare function useSimple(ext: SimpleEChartsExtensionType | (SimpleEChartsExtensionType)[]): void;
diff --git a/src/model/Model.ts b/src/model/Model.ts
index bfeac1c..559c3e9 100644
--- a/src/model/Model.ts
+++ b/src/model/Model.ts
@@ -30,7 +30,7 @@ import TextStyleMixin from './mixin/textStyle';
 import {LineStyleMixin} from './mixin/lineStyle';
 import {ItemStyleMixin} from './mixin/itemStyle';
 import GlobalModel from './Global';
-import { ModelOption } from '../util/types';
+import { AnimationOptionMixin, ModelOption } from '../util/types';
 import { Dictionary } from 'zrender/src/core/types';
 import { mixin, clone, merge } from 'zrender/src/core/util';
 
@@ -42,7 +42,9 @@ type Value<Opt, R> = Opt extends Dictionary<any>
     ? (R extends keyof Opt ? Opt[R] : ModelOption)
     : ModelOption;
 
-class Model<Opt extends ModelOption = ModelOption> {    // TODO: TYPE use unkown insteadof any?
+interface Model<Opt = ModelOption>
+    extends LineStyleMixin, ItemStyleMixin, TextStyleMixin, AreaStyleMixin {}
+class Model<Opt = ModelOption> {    // TODO: TYPE use unkown insteadof any?
 
     // [Caution]: Becuase this class or desecendants can be used as `XXX.extend(subProto)`,
     // the class members must not be initialized in constructor or declaration place.
@@ -127,7 +129,7 @@ class Model<Opt extends ModelOption = ModelOption> {    // TODO: TYPE use unkown
                 val = parentModel.getShallow(key);
             }
         }
-        return val;
+        return val as Opt[R];
     }
 
     // TODO At most 3 depth?
@@ -242,8 +244,8 @@ class Model<Opt extends ModelOption = ModelOption> {    // TODO: TYPE use unkown
     // FIXME:TS check whether put this method here
     isAnimationEnabled(): boolean {
         if (!env.node && this.option) {
-            if (this.option.animation != null) {
-                return !!this.option.animation;
+            if ((this.option as AnimationOptionMixin).animation != null) {
+                return !!(this.option as AnimationOptionMixin).animation;
             }
             else if (this.parentModel) {
                 return this.parentModel.isAnimationEnabled();
@@ -263,7 +265,8 @@ class Model<Opt extends ModelOption = ModelOption> {    // TODO: TYPE use unkown
                 continue;
             }
             // obj could be number/string/... (like 0)
-            obj = (obj && typeof obj === 'object') ? obj[pathArr[i] as keyof ModelOption] : null;
+            obj = (obj && typeof obj === 'object')
+                ? (obj as ModelOption)[pathArr[i] as keyof ModelOption] : null;
             if (obj == null) {
                 break;
             }
@@ -287,7 +290,7 @@ type ModelConstructor = typeof Model
 enableClassExtend(Model as ModelConstructor);
 enableClassCheck(Model as ModelConstructor);
 
-interface Model extends LineStyleMixin, ItemStyleMixin, TextStyleMixin, AreaStyleMixin {}
+
 mixin(Model, LineStyleMixin);
 mixin(Model, ItemStyleMixin);
 mixin(Model, AreaStyleMixin);
diff --git a/test/types/importPartial.ts b/test/types/importPartial.ts
index eae7fe7..140287b 100644
--- a/test/types/importPartial.ts
+++ b/test/types/importPartial.ts
@@ -1,4 +1,4 @@
-import {init, use} from '../../core';
+import {init, use, ComposeOption} from '../../core';
 import {
     BarChart,
     BarSeriesOption,
@@ -10,9 +10,19 @@ import {
     GridComponentOption,
 
     DataZoomComponent,
-    DataZoomComponentOption
+    DataZoomComponentOption,
 } from '../../components';
 
+type Option = ComposeOption<
+    GridComponentOption | DataZoomComponentOption,
+    BarSeriesOption | LineSeriesOption
+>;
+
+const option: Option= {
+    series: [{
+        type: 'bar'
+    }]
+}
 
 use([BarChart, LineChart, GridComponent, DataZoomComponent]);
 
@@ -20,8 +30,4 @@ const dom = document.createElement('div');
 dom.className = 'chart';
 
 const chart = init(dom);
-chart.setOption({
-    series: [{
-        type: 'bar'
-    }]
-});
\ No newline at end of file
+chart.setOption(option);
\ No newline at end of file


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