]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
fix: types and tests (#10660)
authorDan Onoshko <danon0404@gmail.com>
Sat, 10 Sep 2022 15:36:50 +0000 (19:36 +0400)
committerGitHub <noreply@github.com>
Sat, 10 Sep 2022 15:36:50 +0000 (11:36 -0400)
src/core/core.element.ts
src/core/core.scale.js
src/scales/scale.time.js
tsconfig.json
types/helpers/index.d.ts
types/tests/tsconfig.json

index b42df08923a4d67f892b5f01074119d36bbc398f..93006b58ed4fa0ee5c2d3ad3db26963fa0943b18 100644 (file)
@@ -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<T extends AnyObject = AnyObject, O extends AnyObject = AnyObject> {
+export default class Element<T = AnyObject, O = AnyObject> {
 
   static defaults = {};
   static defaultRoutes = undefined;
@@ -28,16 +28,18 @@ export default class Element<T extends AnyObject = AnyObject, O extends AnyObjec
    * @param props - properties to get
    * @param [final] - get the final value (animation target)
    */
-  getProps<P extends (keyof T)[]>(props: P, final?: boolean): Pick<T, P[number]> {
+  getProps<P extends string>(props: P[], final?: boolean): Partial<Record<P, unknown>>;
+  getProps<P extends (keyof T)[]>(props: P, final?: boolean): Pick<T, P[number]>;
+  getProps(props: string[], final?: boolean): Partial<Record<string, unknown>> {
     const anims = this.$animations;
     if (!final || !anims) {
       // let's not create an object, if not needed
-      return this as Pick<T, P[number]>;
+      return this as Record<string, unknown>;
     }
-    const ret: Partial<Pick<T, P[number]>> = {};
+    const ret: Record<string, unknown> = {};
     props.forEach((prop) => {
       ret[prop] = anims[prop] && anims[prop].active() ? anims[prop]._to : this[prop as string];
     });
-    return ret as Pick<T, P[number]>;
+    return ret;
   }
 }
index 4ad607903fdd15f231cebd842e7dc8afe906dd2c..dc479d5fbe29367cdb22e2129ca3ae4e2ee09142 100644 (file)
@@ -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) {
index d783231d6ecca9d2702a0e106ef1917adeaa8b9e..e888de6c7b9906e139acb3358eeca2e1469584e8 100644 (file)
@@ -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;
index ad54c85ea40c1250e02d65b45f47860c8791cc84..ad70b211668689ac23c2e099529e6a789110b81f 100644 (file)
@@ -23,9 +23,7 @@
     "allowSyntheticDefaultImports": true,
     /* Language and Environment */
     "target": "ES6",
-    "lib": ["es2018", "DOM"],
-    /* Completeness */
-    "skipLibCheck": true
+    "lib": ["es2018", "DOM"]
   },
   "typedocOptions": {
     "name": "Chart.js",
index 9753a4d9764192e6094265e5264ad4d6e698dfff..98139076573c97fe9880202459df52e3149ee3c2 100644 (file)
@@ -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';
index 62d8a4c56684026bd6f882464822512f17615a95..48c8ae8c3608339c4a414039709b1489aa3de4c1 100644 (file)
@@ -5,6 +5,7 @@
   },
   "include": [
     "../",
-    "../../src/"
+    "../../src/",
+    "../../dist/**/*.d.ts"
   ]
 }