From: Dan Onoshko Date: Sat, 10 Sep 2022 15:36:50 +0000 (+0400) Subject: fix: types and tests (#10660) X-Git-Tag: v4.0.0~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=83a41c2e0cbad44ca9d4dda56a632a4d3f9b81c6;p=thirdparty%2FChart.js.git fix: types and tests (#10660) --- diff --git a/src/core/core.element.ts b/src/core/core.element.ts index b42df0892..93006b58e 100644 --- a/src/core/core.element.ts +++ b/src/core/core.element.ts @@ -3,7 +3,7 @@ import type {Point} from '../../types/geometric'; import type {Animation} from '../../types/animation'; import {isNumber} from '../helpers/helpers.math'; -export default class Element { +export default class Element { static defaults = {}; static defaultRoutes = undefined; @@ -28,16 +28,18 @@ export default class Element(props: P, final?: boolean): Pick { + getProps

(props: P[], final?: boolean): Partial>; + getProps

(props: P, final?: boolean): Pick; + getProps(props: string[], final?: boolean): Partial> { const anims = this.$animations; if (!final || !anims) { // let's not create an object, if not needed - return this as Pick; + return this as Record; } - const ret: Partial> = {}; + const ret: Record = {}; props.forEach((prop) => { ret[prop] = anims[prop] && anims[prop].active() ? anims[prop]._to : this[prop as string]; }); - return ret as Pick; + return ret; } } diff --git a/src/core/core.scale.js b/src/core/core.scale.js index 4ad607903..dc479d5fb 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -173,7 +173,7 @@ export default class Scale extends Element { this.id = cfg.id; /** @type {string} */ this.type = cfg.type; - /** @type {object} */ + /** @type {any} */ this.options = undefined; /** @type {CanvasRenderingContext2D} */ this.ctx = cfg.ctx; @@ -248,7 +248,7 @@ export default class Scale extends Element { } /** - * @param {object} options + * @param {any} options * @since 3.0 */ init(options) { diff --git a/src/scales/scale.time.js b/src/scales/scale.time.js index d783231d6..e888de6c7 100644 --- a/src/scales/scale.time.js +++ b/src/scales/scale.time.js @@ -263,7 +263,7 @@ export default class TimeScale extends Scale { this._parseOpts = undefined; } - init(scaleOpts, opts) { + init(scaleOpts, opts = {}) { const time = scaleOpts.time || (scaleOpts.time = {}); /** @type {DateAdapter} */ const adapter = this._adapter = new adapters._date(scaleOpts.adapters.date); @@ -412,10 +412,9 @@ export default class TimeScale extends Scale { * They add extra margins on the both sides by scaling down the original scale. * Offsets are added when the `offset` option is true. * @param {number[]} timestamps - * @return {object} * @protected */ - initOffsets(timestamps) { + initOffsets(timestamps = []) { let start = 0; let end = 0; let first, last; diff --git a/tsconfig.json b/tsconfig.json index ad54c85ea..ad70b2116 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -23,9 +23,7 @@ "allowSyntheticDefaultImports": true, /* Language and Environment */ "target": "ES6", - "lib": ["es2018", "DOM"], - /* Completeness */ - "skipLibCheck": true + "lib": ["es2018", "DOM"] }, "typedocOptions": { "name": "Chart.js", diff --git a/types/helpers/index.d.ts b/types/helpers/index.d.ts index 9753a4d97..981390765 100644 --- a/types/helpers/index.d.ts +++ b/types/helpers/index.d.ts @@ -3,7 +3,6 @@ export * from './helpers.collection'; export * from './helpers.color'; export * from './helpers.curve'; export * from './helpers.dom'; -export * from './helpers.easing'; export * from './helpers.extras'; export * from './helpers.interpolation'; export * from './helpers.intl'; diff --git a/types/tests/tsconfig.json b/types/tests/tsconfig.json index 62d8a4c56..48c8ae8c3 100644 --- a/types/tests/tsconfig.json +++ b/types/tests/tsconfig.json @@ -5,6 +5,7 @@ }, "include": [ "../", - "../../src/" + "../../src/", + "../../dist/**/*.d.ts" ] }