Skip to content

Commit b8552ad

Browse files
committed
Fix errors reported by TypeScript compiler
1 parent 1c18a74 commit b8552ad

28 files changed

+542
-117
lines changed

package-lock.json

Lines changed: 127 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
"rollup-plugin-istanbul": "^2.0.1",
7070
"rollup-plugin-node-resolve": "^5.0.0",
7171
"rollup-plugin-terser": "^5.1.3",
72+
"typedoc": "^0.16.9",
73+
"typescript": "^3.7.5",
7274
"yargs": "^14.0.0"
7375
},
7476
"dependencies": {

src/core/core.animation.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const interpolators = {
1818

1919
class Animation {
2020
constructor(cfg, target, prop, to) {
21-
const me = this;
2221
let from = cfg.from;
2322

2423
if (from === undefined) {
@@ -34,16 +33,16 @@ class Animation {
3433
to = from;
3534
}
3635

37-
me._active = true;
38-
me._fn = cfg.fn || interpolators[cfg.type || typeof from];
39-
me._easing = helpers.easing.effects[cfg.easing || 'linear'];
40-
me._start = Math.floor(Date.now() + (cfg.delay || 0));
41-
me._duration = Math.floor(cfg.duration);
42-
me._loop = !!cfg.loop;
43-
me._target = target;
44-
me._prop = prop;
45-
me._from = from;
46-
me._to = to;
36+
this._active = true;
37+
this._fn = cfg.fn || interpolators[cfg.type || typeof from];
38+
this._easing = helpers.easing.effects[cfg.easing || 'linear'];
39+
this._start = Math.floor(Date.now() + (cfg.delay || 0));
40+
this._duration = Math.floor(cfg.duration);
41+
this._loop = !!cfg.loop;
42+
this._target = target;
43+
this._prop = prop;
44+
this._from = from;
45+
this._to = to;
4746
}
4847

4948
active() {

src/core/core.animator.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
import helpers from '../helpers';
44

5+
/**
6+
* @typedef { import("./core.controller") } Chart
7+
*/
8+
59
function drawFPS(chart, count, date, lastDate) {
610
const fps = (1000 / (date - lastDate)) | 0;
711
const ctx = chart.ctx;
@@ -21,6 +25,7 @@ class Animator {
2125
this._request = null;
2226
this._charts = new Map();
2327
this._running = false;
28+
this._lastDate = undefined;
2429
}
2530

2631
/**

src/core/core.controller.js

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -174,24 +174,35 @@ class Chart {
174174

175175
config = initConfig(config);
176176
const initialCanvas = getCanvas(item);
177-
me._initializePlatform(initialCanvas, config);
177+
this.platform = me._initializePlatform(initialCanvas, config);
178178

179179
const context = me.platform.acquireContext(initialCanvas, config);
180180
const canvas = context && context.canvas;
181181
const height = canvas && canvas.height;
182182
const width = canvas && canvas.width;
183183

184-
me.id = helpers.uid();
185-
me.ctx = context;
186-
me.canvas = canvas;
187-
me.config = config;
188-
me.width = width;
189-
me.height = height;
190-
me.aspectRatio = height ? width / height : null;
191-
me.options = config.options;
192-
me._bufferedRender = false;
193-
me._layers = [];
194-
me._metasets = [];
184+
this.id = helpers.uid();
185+
this.ctx = context;
186+
this.canvas = canvas;
187+
this.config = config;
188+
this.width = width;
189+
this.height = height;
190+
this.aspectRatio = height ? width / height : null;
191+
this.options = config.options;
192+
this._bufferedRender = false;
193+
this._layers = [];
194+
this._metasets = [];
195+
this.boxes = [];
196+
this.currentDevicePixelRatio = undefined;
197+
this.chartArea = undefined;
198+
this.data = undefined;
199+
this.active = undefined;
200+
this.lastActive = undefined;
201+
this._lastEvent = undefined;
202+
this._listeners = {};
203+
this._sortedMetasets = [];
204+
this._updating = false;
205+
this.scales = {};
195206

196207
// Add the chart instance to the global namespace
197208
Chart.instances[me.id] = me;
@@ -250,17 +261,14 @@ class Chart {
250261
* @private
251262
*/
252263
_initializePlatform(canvas, config) {
253-
const me = this;
254-
255264
if (config.platform) {
256-
me.platform = new config.platform();
265+
return new config.platform();
257266
} else if (!isDomSupported()) {
258-
me.platform = new BasicPlatform();
267+
return new BasicPlatform();
259268
} else if (window.OffscreenCanvas && canvas instanceof window.OffscreenCanvas) {
260-
me.platform = new BasicPlatform();
261-
} else {
262-
me.platform = new DomPlatform();
269+
return new BasicPlatform();
263270
}
271+
return new DomPlatform();
264272
}
265273

266274
clear() {

src/core/core.element.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import {isNumber} from '../helpers/helpers.math';
55

66
class Element {
77

8-
constructor(configuration) {
9-
if (configuration) {
10-
extend(this, configuration);
11-
}
8+
constructor(cfg) {
9+
this.x = undefined;
10+
this.y = undefined;
11+
this.hidden = undefined;
1212

13-
// this.hidden = false; we assume Element has an attribute called hidden, but do not initialize to save memory
13+
if (cfg) {
14+
extend(this, cfg);
15+
}
1416
}
1517

1618
tooltipPosition() {

src/core/core.interaction.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import helpers from '../helpers/index';
44
import {_isPointInArea} from '../helpers/helpers.canvas';
55
import {_lookup, _rlookup} from '../helpers/helpers.collection';
66

7+
/**
8+
* @typedef { import("./core.controller") } Chart
9+
*/
10+
711
/**
812
* Helper function to get relative position for an event
913
* @param {Event|IEvent} e - The event to get the position for

src/core/core.layouts.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import defaults from './core.defaults';
44
import helpers from '../helpers';
55

6+
/**
7+
* @typedef { import("./core.controller") } Chart
8+
*/
9+
610
const extend = helpers.extend;
711

812
const STATIC_POSITIONS = ['left', 'top', 'right', 'bottom'];

0 commit comments

Comments
 (0)