提交 69d2bccf 编写于 作者: P pissang

chore: generate types when run prepublish

上级 a69b446d
......@@ -184,9 +184,11 @@ todo
/echarts.common.js
/echarts.blank.js
/lib
/types
/index.js
/index.simple.js
/index.common.js
/index.blank.js
/extension-esm
/extension
\ No newline at end of file
/extension
*.tgz
\ No newline at end of file
......@@ -3,7 +3,6 @@
/map/raw
/theme/tool
/theme/thumb
todo
npm-debug.log
/benchmark
echarts.d.ts
\ No newline at end of file
/todo
/npm-debug.log
/benchmark
\ No newline at end of file
......@@ -71,6 +71,9 @@ const extensionSrcDir = nodePath.resolve(ecDir, 'extension-src');
const extensionCJSDir = nodePath.resolve(ecDir, 'extension');
const extensionESMDir = nodePath.resolve(ecDir, 'extension-esm');
const typesDir = nodePath.resolve(ecDir, 'types');
const compileWorkList = [
{
logLabel: 'main ts -> js-cjs',
......@@ -117,7 +120,10 @@ const compileWorkList = [
compilerOptionsOverride: {
module: 'ES2015',
rootDir: ecDir,
outDir: tmpDir
outDir: tmpDir,
// Generate types when buidling esm
declaration: true,
declarationDir: typesDir
},
srcGlobby: mainSrcGlobby,
transformOptions: {
......@@ -237,9 +243,7 @@ async function tsCompile(compilerOptionsOverride, srcPathList) {
let compilerOptions = {
...tsConfig.compilerOptions,
...compilerOptionsOverride,
sourceMap: false,
// Use the esm d.ts
declaration: false
sourceMap: false
};
// Must do it. becuase the value in tsconfig.json might be different from the inner representation.
......
export * from './echarts.all';
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
///////////////////////////////////////////////////////////////////////
/// NOTE: types folder is generated by `npm run prepublish` command ///
/// Make sure run it before edit this file. ///
///////////////////////////////////////////////////////////////////////
export * from './types/echarts.all';
export {EChartsFullOption as EChartsOption} from './types/src/option';
\ No newline at end of file
......@@ -10,6 +10,7 @@
"main": "index.js",
"module": "echarts.all.js",
"jsdelivr": "dist/echarts.min.js",
"types": "index.d.ts",
"homepage": "http://echarts.apache.org",
"repository": {
"type": "git",
......
......@@ -103,6 +103,8 @@ import 'zrender/src/canvas/canvas';
import { registerExternalTransform } from './data/helper/transform';
import { createLocaleObject, SYSTEM_LANG, LocaleOption } from './locale';
import type {EChartsFullOption} from './option';
declare let global: any;
type ModelFinder = modelUtil.ModelFinder;
......@@ -255,7 +257,6 @@ let enableConnect: (ecIns: ECharts) => void;
let markStatusToUpdate: (ecIns: ECharts) => void;
let applyChangedStates: (ecIns: ECharts) => void;
class ECharts extends Eventful {
/**
......@@ -487,9 +488,10 @@ class ECharts extends Eventful {
* @param opts.silent Default `false`.
* @param opts.replaceMerge Default undefined.
*/
setOption(option: ECOption, notMerge?: boolean, lazyUpdate?: boolean): void;
setOption(option: ECOption, opts?: SetOptionOpts): void;
setOption(option: ECOption, notMerge?: boolean | SetOptionOpts, lazyUpdate?: boolean): void {
// Expose to user full option.
setOption(option: EChartsFullOption, notMerge?: boolean, lazyUpdate?: boolean): void;
setOption(option: EChartsFullOption, opts?: SetOptionOpts): void;
setOption(option: EChartsFullOption, notMerge?: boolean | SetOptionOpts, lazyUpdate?: boolean): void {
if (__DEV__) {
assert(!this[IN_MAIN_PROCESS_KEY], '`setOption` should not be called during main process.');
}
......@@ -517,7 +519,7 @@ class ECharts extends Eventful {
ecModel.init(null, null, null, theme, this._locale, optionManager);
}
this._model.setOption(option, {replaceMerge: replaceMerge}, optionPreprocessorFuncs);
this._model.setOption(option as ECOption, {replaceMerge: replaceMerge}, optionPreprocessorFuncs);
if (lazyUpdate) {
this[OPTION_UPDATED_KEY] = {silent: silent};
......@@ -551,8 +553,8 @@ class ECharts extends Eventful {
return this._model;
}
getOption(): ECUnitOption {
return this._model && this._model.getOption();
getOption(): EChartsFullOption {
return this._model && this._model.getOption() as EChartsFullOption;
}
getWidth(): number {
......@@ -2788,4 +2790,4 @@ registerTheme('dark', darkTheme);
// be mounted on `echarts` is the extension `dataTool` is imported.
export const dataTool = {};
export interface EChartsType extends ECharts {}
export interface EChartsType extends ECharts {}
\ No newline at end of file
......@@ -17,56 +17,57 @@
* under the License.
*/
import {GridOption} from './src/coord/cartesian/GridModel';
import {PolarOption} from './src/coord/polar/PolarModel';
import {GeoOption} from './src/coord/geo/GeoModel';
import {SingleAxisOption} from './src/coord/single/AxisModel';
import {ParallelAxisOption} from './src/coord/parallel/AxisModel';
import {ParallelCoordinateSystemOption} from './src/coord/parallel/ParallelModel';
import {CalendarOption} from './src/coord/calendar/CalendarModel';
import {ToolboxOption} from './src/component/toolbox/ToolboxModel';
import {TooltipOption} from './src/component/tooltip/TooltipModel';
import {AxisPointerOption} from './src/component/axisPointer/AxisPointerModel';
import {BrushOption} from './src/component/brush/BrushModel';
import {TitleOption} from './src/component/title';
import type {GridOption} from './coord/cartesian/GridModel';
import type {PolarOption} from './coord/polar/PolarModel';
import type {GeoOption} from './coord/geo/GeoModel';
import type {SingleAxisOption} from './coord/single/AxisModel';
import type {ParallelAxisOption} from './coord/parallel/AxisModel';
import type {ParallelCoordinateSystemOption} from './coord/parallel/ParallelModel';
import type {CalendarOption} from './coord/calendar/CalendarModel';
import type {ToolboxOption} from './component/toolbox/ToolboxModel';
import type {TooltipOption} from './component/tooltip/TooltipModel';
import type {AxisPointerOption} from './component/axisPointer/AxisPointerModel';
import type {BrushOption} from './component/brush/BrushModel';
import type {TitleOption} from './component/title';
import {TimelineOption} from './src/component/timeline/TimelineModel';
import {SliderTimelineOption} from './src/component/timeline/SliderTimelineModel';
import type {TimelineOption} from './component/timeline/TimelineModel';
import type {SliderTimelineOption} from './component/timeline/SliderTimelineModel';
import {LegendOption} from './src/component/legend/LegendModel';
import {ScrollableLegendOption} from './src/component/legend/ScrollableLegendModel';
import type {LegendOption} from './component/legend/LegendModel';
import type {ScrollableLegendOption} from './component/legend/ScrollableLegendModel';
import {DataZoomOption} from './src/component/dataZoom/DataZoomModel';
import {SliderDataZoomOption} from './src/component/dataZoom/SliderZoomModel';
import {InsideDataZoomOption} from './src/component/dataZoom/InsideZoomModel';
import type {DataZoomOption} from './component/dataZoom/DataZoomModel';
import type {SliderDataZoomOption} from './component/dataZoom/SliderZoomModel';
import type {InsideDataZoomOption} from './component/dataZoom/InsideZoomModel';
import {VisualMapOption} from './src/component/visualMap/VisualMapModel';
import {ContinousVisualMapOption} from './src/component/visualMap/ContinuousModel';
import {PiecewiseVisualMapOption} from './src/component/visualMap/PiecewiseModel';
import type {VisualMapOption} from './component/visualMap/VisualMapModel';
import type {ContinousVisualMapOption} from './component/visualMap/ContinuousModel';
import type {PiecewiseVisualMapOption} from './component/visualMap/PiecewiseModel';
import {LineSeriesOption} from './src/chart/line/LineSeries';
import {BarSeriesOption} from './src/chart/bar/BarSeries';
import {ScatterSeriesOption} from './src/chart/scatter/ScatterSeries';
import {RadarSeriesOption} from './src/chart/radar/RadarSeries';
import {MapSeriesOption} from './src/chart/map/MapSeries';
import {TreeSeriesOption} from './src/chart/tree/TreeSeries';
import {TreemapSeriesOption} from './src/chart/treemap/TreemapSeries';
import {GraphSeriesOption} from './src/chart/graph/GraphSeries';
import {GaugeSeriesOption} from './src/chart/gauge/GaugeSeries';
import {FunnelSeriesOption} from './src/chart/funnel/FunnelSeries';
import {ParallelSeriesOption} from './src/chart/parallel/ParallelSeries';
import {SankeySeriesOption} from './src/chart/sankey/SankeySeries';
import {BoxplotSeriesOption} from './src/chart/boxplot/BoxplotSeries';
import {CandlestickSeriesOption} from './src/chart/candlestick/CandlestickSeries';
import {EffectScatterSeriesOption} from './src/chart/effectScatter/EffectScatterSeries';
import {LinesSeriesOption} from './src/chart/lines/LinesSeries';
import {HeatmapSeriesOption} from './src/chart/heatmap/HeatmapSeries';
import {PictorialBarSeriesOption} from './src/chart/bar/PictorialBarSeries';
import {ThemeRiverSeriesOption} from './src/chart/themeRiver/ThemeRiverSeries';
import {SunburstSeriesOption} from './src/chart/sunburst/SunburstSeries';
import type {LineSeriesOption} from './chart/line/LineSeries';
import type {BarSeriesOption} from './chart/bar/BarSeries';
import type {ScatterSeriesOption} from './chart/scatter/ScatterSeries';
import type {RadarSeriesOption} from './chart/radar/RadarSeries';
import type {MapSeriesOption} from './chart/map/MapSeries';
import type {TreeSeriesOption} from './chart/tree/TreeSeries';
import type {TreemapSeriesOption} from './chart/treemap/TreemapSeries';
import type {GraphSeriesOption} from './chart/graph/GraphSeries';
import type {GaugeSeriesOption} from './chart/gauge/GaugeSeries';
import type {FunnelSeriesOption} from './chart/funnel/FunnelSeries';
import type {ParallelSeriesOption} from './chart/parallel/ParallelSeries';
import type {SankeySeriesOption} from './chart/sankey/SankeySeries';
import type {BoxplotSeriesOption} from './chart/boxplot/BoxplotSeries';
import type {CandlestickSeriesOption} from './chart/candlestick/CandlestickSeries';
import type {EffectScatterSeriesOption} from './chart/effectScatter/EffectScatterSeries';
import type {LinesSeriesOption} from './chart/lines/LinesSeries';
import type {HeatmapSeriesOption} from './chart/heatmap/HeatmapSeries';
import type {PictorialBarSeriesOption} from './chart/bar/PictorialBarSeries';
import type {ThemeRiverSeriesOption} from './chart/themeRiver/ThemeRiverSeries';
import type {SunburstSeriesOption} from './chart/sunburst/SunburstSeries';
import { ECOption } from './util/types';
export interface EChartsOption {
export interface EChartsFullOption extends ECOption {
title?: TitleOption | TitleOption[]
grid?: GridOption | GridOption[]
polar?: PolarOption | PolarOption[]
......@@ -79,7 +80,7 @@ export interface EChartsOption {
tooltip?: TooltipOption | TooltipOption[]
axisPointer?: AxisPointerOption | AxisPointerOption[]
brush?: BrushOption | BrushOption[]
timeline?: TimelineOption | SliderTimelineOption | (TimelineOption | SliderTimelineOption)[]
timeline?: TimelineOption | SliderTimelineOption
legend?: LegendOption | ScrollableLegendOption | (LegendOption | ScrollableLegendOption)[]
dataZoom?: SliderDataZoomOption | InsideDataZoomOption | (SliderDataZoomOption | InsideDataZoomOption)[]
visualMap?: (ContinousVisualMapOption | PiecewiseVisualMapOption)[]
......@@ -104,4 +105,7 @@ export interface EChartsOption {
| PictorialBarSeriesOption
| ThemeRiverSeriesOption
| SunburstSeriesOption)[]
options?: EChartsFullOption[]
baseOption?: EChartsFullOption
}
\ No newline at end of file
......@@ -418,9 +418,9 @@ export type SeriesDataType = 'main' | 'node' | 'edge';
*/
export type ECUnitOption = {
// Exclude these reserverd word for `ECOption` to avoid to infer to "any".
baseOption?: never
options?: never
media?: never
baseOption?: unknown
options?: unknown
media?: unknown
timeline?: ComponentOption | ComponentOption[]
backgroundColor?: ZRColor
......@@ -470,7 +470,7 @@ export type ECUnitOption = {
* };
* ```
*/
export type ECOption = ECUnitOption | {
export interface ECOption extends ECUnitOption {
baseOption?: ECUnitOption,
timeline?: ComponentOption,
options?: ECUnitOption[],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册