Skip to content

Commit

Permalink
fix(types): Fix donut option types
Browse files Browse the repository at this point in the history
- Update missing param types for donut.ratio
- Remove unused npm script for type cheking
- Add dtslint to be checked before push

Fix #1615
  • Loading branch information
netil committed Aug 21, 2020
1 parent ce42768 commit 1917169
Show file tree
Hide file tree
Showing 9 changed files with 279 additions and 65 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"module": "dist/billboard.esm.js",
"types": "types/index.d.ts",
"scripts": {
"check-types": "tsc",
"start": "webpack-dev-server --open",
"start:plugin": "cross-env PLUGIN=true webpack-dev-server --open",
"build": "npm run build:production && npm run build:packaged && npm run build:theme && npm run build:plugin && npm run build:esm",
Expand All @@ -20,8 +19,8 @@
"build:packaged:analyzer": "cross-env ANALYZER=true npm run build:packaged",
"build:plugin": "cross-env NODE_ENV=plugin webpack && cross-env NODE_ENV=plugin MIN=true webpack",
"release": "semantic-release",
"type-check": "tsc --noEmit",
"lint": "eslint src --ext .ts",
"lint:types": "dtslint --onlyTestTsNext types",
"loc": "cloc --by-file src",
"test": "node --max-old-space-size=3072 ./node_modules/karma/bin/karma start",
"test:chrome": "npm test -- --chrome",
Expand All @@ -37,7 +36,7 @@
"husky": {
"hooks": {
"commit-msg": "commitlint -g ./config/commitlint.config.js -E HUSKY_GIT_PARAMS",
"pre-push": "npm run lint"
"pre-push": "npm run lint && npm run lint:types"
}
},
"repository": {
Expand Down Expand Up @@ -137,6 +136,7 @@
"d3-polygon": "^1.0.6",
"d3-voronoi": "^1.1.4",
"docdash": "^1.2.0",
"dtslint": "^3.7.0",
"eslint": "^7.7.0",
"eslint-config-naver": "^2.1.0",
"eslint-loader": "^4.0.2",
Expand Down
1 change: 0 additions & 1 deletion types/axis.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export interface AxisConfigurationBase {
* Set additional axes for Axis
*/
axes?: AxesConfiguration[];

}

export interface xAxisConfiguration extends AxisConfigurationBase {
Expand Down
36 changes: 18 additions & 18 deletions types/bb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ export const bb: {
};

// shape modules
export const area: () => "area";
export const areaLineRange: () => "area-line-range";
export const areaSpline: () => "area-spline";
export const areaSplineRange: () => "area-spline-range";
export const areaStep: () => "area-step";
export const bar: () => "bar";
export const bubble: () => "bubble";
export const donut: () => "donut";
export const gauge: () => "gauge";
export const line: () => "line";
export const pie: () => "pie";
export const radar: () => "radar";
export const scatter: () => "scatter";
export const spline: () => "spline";
export const step: () => "step";
export function area(): "area";
export function areaLineRange(): "area-line-range";
export function areaSpline(): "area-spline";
export function areaSplineRange(): "area-spline-range";
export function areaStep(): "area-step";
export function bar(): "bar";
export function bubble(): "bubble";
export function donut(): "donut";
export function gauge(): "gauge";
export function line(): "line";
export function pie(): "pie";
export function radar(): "radar";
export function scatter(): "scatter";
export function spline(): "spline";
export function step(): "step";

// interaction modules
export const selection: () => true;
export const subchart: () => true;
export const zoom: () => true;
export function selection(): true;
export function subchart(): true;
export function zoom(): true;
10 changes: 5 additions & 5 deletions types/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export interface ChartOptions {
*
* Passing 'null' will not set a color for these elements, which requires the usage of custom CSS-based theming to work.
*/
pattern?: (string|null)[];
pattern?: Array<(string|null)>;

/**
* color threshold for gauge and tooltip color
Expand Down Expand Up @@ -492,7 +492,7 @@ export interface ChartOptions {
/**
* Set ratio of labels position.
*/
ratio? : number | ((this: Chart, d, radius, h) => number)
ratio?: number | ((this: Chart, d: DataItem, radius: number, h: number) => number)

/**
* Set threshold ratio to show/hide labels.
Expand Down Expand Up @@ -699,7 +699,7 @@ export interface ChartOptions {
/**
* Set plugins
*/
plugins?: (Bubblecompare | Stanford | TextOverlap)[];
plugins?: Array<(Bubblecompare | Stanford | TextOverlap)>;

/**
* Control the render timing
Expand Down Expand Up @@ -750,7 +750,7 @@ export interface ChartOptions {
* Set the position. Default value is 'center'
*/
position?: "center" | "right" | "left";
}
};
}

export interface AreaLinearGradientOptions {
Expand All @@ -771,7 +771,7 @@ export interface AreaLinearGradientOptions {
* - setting 'null' for stop-color, will set its original data color
* - setting 'function' for stop-color, will pass data id as argument. It should return color string or null value
*/
stops?: [number, string | null | ((this: Chart, id: string) => string), number][];
stops?: Array<[number, string | null | ((this: Chart, id: string) => string), number]>;
}

export interface RegionOptions {
Expand Down
8 changes: 4 additions & 4 deletions types/plugin/bubblecompare/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {Plugin} from "../plugin";
import {BubblecompareOptions} from "./options";

export default class Bubblecompare extends Plugin {
/**
* Generate stanford diagram
*/
constructor(options: BubblecompareOptions);
/**
* Generate stanford diagram
*/
constructor(options: BubblecompareOptions);
}
24 changes: 12 additions & 12 deletions types/plugin/bubblecompare/options.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export interface BubblecompareOptions {
/**
* Minimum bubble radius (px, default: 11)
*/
minR?: number;
/**
* Maximum bubble radius (px, default: 11)
*/
maxR?: number;
/**
* expand ratio when bubble focused (default: 1)
*/
expandScale?: number;
/**
* Minimum bubble radius (px, default: 11)
*/
minR?: number;
/**
* Maximum bubble radius (px, default: 11)
*/
maxR?: number;
/**
* expand ratio when bubble focused (default: 1)
*/
expandScale?: number;
}
3 changes: 2 additions & 1 deletion types/tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"rules": {
"semicolon": true,
"indent": [true, "tabs", 4],
"jsdoc-format": false
"jsdoc-format": false,
"whitespace": [false, "check-module"]
}
}
8 changes: 4 additions & 4 deletions types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ export interface TargetIds {
ids: string[] | string;
}

export type DataRow = {
export interface DataRow {
id: string;
id_org: string; // eslint-disable-line camelcase
values: DataItem[]
};
values: DataItem[];
}

export interface DataItem {
id: string;
Expand All @@ -45,7 +45,7 @@ export interface DataItem {
ratio?: number;
}

export type DataArray = Array<DataRow>;
export type DataArray = DataRow[];

export interface RegionsType {
[key: string]: {
Expand Down

0 comments on commit 1917169

Please sign in to comment.