]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Preparing the project for TypeScript (#10595)
authorDan Onoshko <danon0404@gmail.com>
Mon, 22 Aug 2022 15:58:57 +0000 (19:58 +0400)
committerGitHub <noreply@github.com>
Mon, 22 Aug 2022 15:58:57 +0000 (11:58 -0400)
* Add Typescript to the build
* Converts the `helpers.core` to Typescript as an example
* Converts the `core.element` to Typescript

78 files changed:
.eslintrc.yml
.size-limit.cjs
auto/auto.d.ts
docs/developers/charts.md
helpers/helpers.d.ts
karma.conf.cjs
package-lock.json
package.json
rollup.config.js
src/core/core.adapters.js [deleted file]
src/core/core.adapters.ts [new file with mode: 0644]
src/core/core.element.js [deleted file]
src/core/core.element.ts [new file with mode: 0644]
src/core/core.ticks.js
src/core/index.ts [moved from src/core/index.js with 92% similarity]
src/elements/element.arc.js
src/elements/element.bar.js
src/elements/element.point.js
src/helpers/helpers.core.ts [moved from src/helpers/helpers.core.js with 51% similarity]
src/helpers/helpers.options.js
src/helpers/index.ts [moved from src/helpers/index.js with 100% similarity]
src/helpers/types.ts [new file with mode: 0644]
src/index.ts [moved from src/index.js with 100% similarity]
src/index.umd.ts [moved from src/index.umd.js with 93% similarity]
src/plugins/plugin.filler/filler.options.js
src/plugins/plugin.tooltip.js
src/scales/scale.time.js
src/types.ts [new file with mode: 0644]
tsconfig.json
types/.eslintrc.yml
types/adapters.d.ts [deleted file]
types/animation.d.ts
types/element.d.ts [deleted file]
types/helpers/helpers.core.d.ts [deleted file]
types/helpers/helpers.easing.d.ts
types/helpers/index.d.ts
types/index.d.ts
types/tests/animation.ts
types/tests/autogen.js
types/tests/chart_types.ts
types/tests/controllers/bubble_chart_options.ts
types/tests/controllers/doughnut_meta_total.ts
types/tests/controllers/doughnut_offset.ts
types/tests/controllers/doughnut_outer_radius.ts
types/tests/controllers/line_scriptable_parsed_data.ts
types/tests/controllers/line_segments.ts
types/tests/controllers/line_span_gaps.ts
types/tests/controllers/line_styling_array.ts
types/tests/controllers/radar_dataset_indexable_options.ts
types/tests/data_types.ts
types/tests/dataset_null_data.ts
types/tests/date_adapter.ts [new file with mode: 0644]
types/tests/defaults.ts
types/tests/elements/scriptable_element_options.ts
types/tests/extensions/plugin.ts
types/tests/extensions/scale.ts
types/tests/interaction.ts
types/tests/layout/position.ts
types/tests/options.ts
types/tests/overrides.ts
types/tests/parsed.data.type.ts
types/tests/plugins/defaults.ts
types/tests/plugins/plugin.decimation/decimation_algorithm.ts
types/tests/plugins/plugin.filler/fill_target_true.ts
types/tests/plugins/plugin.tooltip/chart.tooltip.ts
types/tests/plugins/plugin.tooltip/tooltip_dataset_type.ts
types/tests/plugins/plugin.tooltip/tooltip_parsed_data.ts
types/tests/plugins/plugin.tooltip/tooltip_parsed_data_chart_defaults.ts
types/tests/plugins/plugin.tooltip/tooltip_scriptable_background_color.ts
types/tests/register.ts
types/tests/scales/chart_options.ts
types/tests/scales/options.ts
types/tests/scales/time_string_max.ts
types/tests/scriptable.ts
types/tests/scriptable_core_chart_options.ts
types/tests/test_instance_assignment.ts
types/tests/tsconfig.json
types/utils.d.ts

index f3ca59d8e9d8229d7c86d7615a18d5e370da49d2..7b8c853a909b3c9df7c27780030b00735589cd19 100644 (file)
@@ -36,3 +36,24 @@ rules:
   es/no-regexp-s-flag: "error"
   es/no-regexp-unicode-property-escapes: "error"
   es/no-dynamic-import: "off"
+
+overrides:
+  - files: ['**/*.ts']
+    parser: '@typescript-eslint/parser'
+    plugins:
+      - '@typescript-eslint'
+    extends:
+      - chartjs
+      - plugin:@typescript-eslint/recommended
+
+    rules:
+      # Replace stock eslint rules with typescript-eslint equivalents for proper
+      # TypeScript support.
+      indent: "off"
+      "@typescript-eslint/indent": ["error", 2]
+      no-use-before-define: "off"
+      '@typescript-eslint/no-use-before-define': "error"
+      no-shadow: "off"
+      '@typescript-eslint/no-shadow': "error"
+      space-before-function-paren: "off"
+      '@typescript-eslint/space-before-function-paren': [2, never]
index b2026cd49be08d71fa5e5ea67b62097d72ceb7a4..e201a0ca6a5f8093957099872b213db4531ae57e 100644 (file)
@@ -7,7 +7,7 @@ function modifyWebpackConfig(config) {
 module.exports = [
   {
     path: 'dist/chart.js',
-    limit: '75 KB',
+    limit: '77 KB',
     webpack: false,
     running: false
   },
index 566f043ac702935c8604a652b70e9bc3208a0f57..487acb610fabd72f13d83262154d396be07337e7 100644 (file)
@@ -1,4 +1,4 @@
-import {Chart} from '../types';
+import {Chart} from '../dist/types';
 
-export * from '../types';
+export * from '../dist/types';
 export default Chart;
index c37cace2c5042931d735c9d04b384a345bf61300..feb63fc413a738aa8d481aaaf1306d5c9f9611aa 100644 (file)
@@ -130,8 +130,8 @@ When adding a new chart type, `ChartTypeRegistry` must contains the declarations
 
 For example, to provide typings for a new chart type that extends from a bubble chart, you would add a `.d.ts` containing:
 
-```ts
-import { ChartTypeRegistry } from 'chart.js'
+```typescript
+import { ChartTypeRegistry } from 'chart.js';
 
 declare module 'chart.js' {
     interface ChartTypeRegistry {
index 2c3468e72981720241dafe2175923803ea341f48..587d0fd55616e8d6db147b607814c664d7e346c0 100644 (file)
@@ -1 +1 @@
-export * from '../types/helpers';
+export * from '../dist/helpers/types';
index cb8839fce229b13b86278162b166d346701d9068..f9764bafc4df29b6200b967cdd223f683c94cfda 100644 (file)
@@ -27,11 +27,9 @@ module.exports = async function(karma) {
   }
 
   if (args.coverage) {
-    build.plugins = [
-      json(),
-      resolve(),
+    build.plugins.push(
       istanbul({exclude: ['node_modules/**/*.js', 'package.json']})
-    ];
+    );
   }
 
   karma.set({
@@ -92,14 +90,14 @@ module.exports = async function(karma) {
       'node_modules/moment-timezone/builds/moment-timezone-with-data.min.js',
       {pattern: 'test/index.js', watched: false},
       {pattern: 'test/BasicChartWebWorker.js', included: false},
-      {pattern: 'src/index.umd.js', watched: false},
+      {pattern: 'src/index.umd.ts', watched: false},
       'node_modules/chartjs-adapter-moment/dist/chartjs-adapter-moment.js',
       {pattern: specPattern}
     ],
 
     preprocessors: {
       'test/index.js': ['rollup'],
-      'src/index.umd.js': ['sources']
+      'src/index.umd.ts': ['sources']
     },
 
     rollupPreprocessor: {
index 2c110bede623534fcbbff6b657cb2ff0d3e61662..c968bcfa52d654a0ccb6deca316682bd3e9af5e9 100644 (file)
@@ -16,6 +16,7 @@
                 "@rollup/plugin-node-resolve": "^13.3.0",
                 "@simonbrunel/vuepress-plugin-versions": "^0.2.0",
                 "@size-limit/preset-big-lib": "^8.0.0",
+                "@swc/core": "^1.2.224",
                 "@types/estree": "^1.0.0",
                 "@types/offscreencanvas": "^2019.7.0",
                 "@typescript-eslint/eslint-plugin": "^5.32.0",
@@ -56,6 +57,7 @@
                 "rollup": "^2.77.2",
                 "rollup-plugin-cleanup": "^3.2.1",
                 "rollup-plugin-istanbul": "^3.0.0",
+                "rollup-plugin-swc3": "^0.3.0",
                 "rollup-plugin-terser": "^7.0.2",
                 "size-limit": "^8.0.0",
                 "typedoc": "^0.23.10",
                 "node": ">=10.13.0"
             }
         },
+        "node_modules/@swc/core": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.2.224.tgz",
+            "integrity": "sha512-K0B0QKT0eSpPlL4amWJzllYJigQdE7+ha6VQVks6g/oiko1yMYP8lGcCKOKb+KuvW1ltPzlyFqi7h7ryEVG2vQ==",
+            "dev": true,
+            "hasInstallScript": true,
+            "bin": {
+                "swcx": "run_swcx.js"
+            },
+            "engines": {
+                "node": ">=10"
+            },
+            "funding": {
+                "type": "opencollective",
+                "url": "https://opencollective.com/swc"
+            },
+            "optionalDependencies": {
+                "@swc/core-android-arm-eabi": "1.2.224",
+                "@swc/core-android-arm64": "1.2.224",
+                "@swc/core-darwin-arm64": "1.2.224",
+                "@swc/core-darwin-x64": "1.2.224",
+                "@swc/core-freebsd-x64": "1.2.224",
+                "@swc/core-linux-arm-gnueabihf": "1.2.224",
+                "@swc/core-linux-arm64-gnu": "1.2.224",
+                "@swc/core-linux-arm64-musl": "1.2.224",
+                "@swc/core-linux-x64-gnu": "1.2.224",
+                "@swc/core-linux-x64-musl": "1.2.224",
+                "@swc/core-win32-arm64-msvc": "1.2.224",
+                "@swc/core-win32-ia32-msvc": "1.2.224",
+                "@swc/core-win32-x64-msvc": "1.2.224"
+            }
+        },
+        "node_modules/@swc/core-android-arm-eabi": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-android-arm-eabi/-/core-android-arm-eabi-1.2.224.tgz",
+            "integrity": "sha512-viVOYrhSqNxdDOCNu2UUfiAK0qjkmk/fB9mObdSb+48JlHv4kYBnSLjaIhj0NlXCsxgetH7QFbjrKXRJ+gpHqw==",
+            "cpu": [
+                "arm"
+            ],
+            "dev": true,
+            "optional": true,
+            "os": [
+                "android"
+            ],
+            "dependencies": {
+                "@swc/wasm": "1.2.122"
+            },
+            "engines": {
+                "node": ">=10"
+            }
+        },
+        "node_modules/@swc/core-android-arm64": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-android-arm64/-/core-android-arm64-1.2.224.tgz",
+            "integrity": "sha512-HCfdnVyslhMX25BDOqE7rOcl3a6QHs34O3xLLY2J/wg2ICtbxehpbpBPrp+VBG3Ngv7VGD9OPhmFgGxElFtZLQ==",
+            "cpu": [
+                "arm64"
+            ],
+            "dev": true,
+            "optional": true,
+            "os": [
+                "android"
+            ],
+            "dependencies": {
+                "@swc/wasm": "1.2.130"
+            },
+            "engines": {
+                "node": ">=10"
+            }
+        },
+        "node_modules/@swc/core-android-arm64/node_modules/@swc/wasm": {
+            "version": "1.2.130",
+            "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+            "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+            "dev": true,
+            "optional": true
+        },
+        "node_modules/@swc/core-darwin-arm64": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.2.224.tgz",
+            "integrity": "sha512-jzv8Eop0GDe4owRDWr02n/xT7Bm6eTFWoM3nFXOM865gNYfASGGm3HHm4z20yndIxq5xuKHcOOH9QXQQhe/lQA==",
+            "cpu": [
+                "arm64"
+            ],
+            "dev": true,
+            "optional": true,
+            "os": [
+                "darwin"
+            ],
+            "engines": {
+                "node": ">=10"
+            }
+        },
+        "node_modules/@swc/core-darwin-x64": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.2.224.tgz",
+            "integrity": "sha512-hpdJt/BJ45+hcgs461nJxgMJVNN/2uJL8TLvFxeOJiDpF4r1elRxYfDC1W8ctMWB3eB3Wepz3Ku2z8l9UgPnyQ==",
+            "cpu": [
+                "x64"
+            ],
+            "dev": true,
+            "optional": true,
+            "os": [
+                "darwin"
+            ],
+            "engines": {
+                "node": ">=10"
+            }
+        },
+        "node_modules/@swc/core-freebsd-x64": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-freebsd-x64/-/core-freebsd-x64-1.2.224.tgz",
+            "integrity": "sha512-bVIXwwjYA1ZdMKTwrAosxG808nQqvHhzs/fOKUrl1VeZ9CTHA0FzpSXwaBf1shbUVKvQVPKydY0K5q9dkSUkpw==",
+            "cpu": [
+                "x64"
+            ],
+            "dev": true,
+            "optional": true,
+            "os": [
+                "freebsd"
+            ],
+            "dependencies": {
+                "@swc/wasm": "1.2.130"
+            },
+            "engines": {
+                "node": ">=10"
+            }
+        },
+        "node_modules/@swc/core-freebsd-x64/node_modules/@swc/wasm": {
+            "version": "1.2.130",
+            "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+            "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+            "dev": true,
+            "optional": true
+        },
+        "node_modules/@swc/core-linux-arm-gnueabihf": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.2.224.tgz",
+            "integrity": "sha512-MY3UQI3IOjME5TpuIhwI0lqKHsU3x7BwlU4n/mLNe2lH3DLaP0rrGHCMI2iJqfiYKU1Rg1r01HXmysuiriF1TA==",
+            "cpu": [
+                "arm"
+            ],
+            "dev": true,
+            "optional": true,
+            "os": [
+                "linux"
+            ],
+            "dependencies": {
+                "@swc/wasm": "1.2.130"
+            },
+            "engines": {
+                "node": ">=10"
+            }
+        },
+        "node_modules/@swc/core-linux-arm-gnueabihf/node_modules/@swc/wasm": {
+            "version": "1.2.130",
+            "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+            "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+            "dev": true,
+            "optional": true
+        },
+        "node_modules/@swc/core-linux-arm64-gnu": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.2.224.tgz",
+            "integrity": "sha512-tEpaGq4wp79tR+4s0h8xbzcxW6tZOfb2/Jf1vrmRYfRBqryBRTdtn14Rfy4qlK3s/SC3NfI2MKxZRgcGnMCeWw==",
+            "cpu": [
+                "arm64"
+            ],
+            "dev": true,
+            "optional": true,
+            "os": [
+                "linux"
+            ],
+            "engines": {
+                "node": ">=10"
+            }
+        },
+        "node_modules/@swc/core-linux-arm64-musl": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.2.224.tgz",
+            "integrity": "sha512-jnrYqXc7aRzBnEqEp3nAi9tjuUhBnN0pSKiHJytlBP1QkXnH7HD44Da9udmKUFYB5hHpwaXE0NIh7jK0nSMnhw==",
+            "cpu": [
+                "arm64"
+            ],
+            "dev": true,
+            "optional": true,
+            "os": [
+                "linux"
+            ],
+            "engines": {
+                "node": ">=10"
+            }
+        },
+        "node_modules/@swc/core-linux-x64-gnu": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.2.224.tgz",
+            "integrity": "sha512-UBkeDlG+PrIXDH1sR4EIXN5qK4a677IHb6RBghbvBDJS61X9/nTDxtCF7/zCqDxJRahhUrT6lDsYpuLCws2hiw==",
+            "cpu": [
+                "x64"
+            ],
+            "dev": true,
+            "optional": true,
+            "os": [
+                "linux"
+            ],
+            "engines": {
+                "node": ">=10"
+            }
+        },
+        "node_modules/@swc/core-linux-x64-musl": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.2.224.tgz",
+            "integrity": "sha512-CQMGDzxKvkzf6TOdaWnmhb6uk1XEhM/mM3BDfX+hx9j3Hg3bFw9qmPvrkoWI2G8J50MvpoR1iPBYyG2LNeQWeg==",
+            "cpu": [
+                "x64"
+            ],
+            "dev": true,
+            "optional": true,
+            "os": [
+                "linux"
+            ],
+            "engines": {
+                "node": ">=10"
+            }
+        },
+        "node_modules/@swc/core-win32-arm64-msvc": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.2.224.tgz",
+            "integrity": "sha512-03V4apubsOhLKQNmfWGlgvDCJkhlh0ZOHcGddxb7bD4PeP6U0lnABG3hlz2uicwcIGBPu/p7jtm5/hezeiXE6Q==",
+            "cpu": [
+                "arm64"
+            ],
+            "dev": true,
+            "optional": true,
+            "os": [
+                "win32"
+            ],
+            "dependencies": {
+                "@swc/wasm": "1.2.130"
+            },
+            "engines": {
+                "node": ">=10"
+            }
+        },
+        "node_modules/@swc/core-win32-arm64-msvc/node_modules/@swc/wasm": {
+            "version": "1.2.130",
+            "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+            "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+            "dev": true,
+            "optional": true
+        },
+        "node_modules/@swc/core-win32-ia32-msvc": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.2.224.tgz",
+            "integrity": "sha512-gPOmIdhCwkb5BbDiPs/4t1LIElFLoQwiv45XwK5wADh1qzLD3A8EtpnpXfLsjL/fUMlLIGCgHQ6BQ0x04VrI1Q==",
+            "cpu": [
+                "ia32"
+            ],
+            "dev": true,
+            "optional": true,
+            "os": [
+                "win32"
+            ],
+            "dependencies": {
+                "@swc/wasm": "1.2.130"
+            },
+            "engines": {
+                "node": ">=10"
+            }
+        },
+        "node_modules/@swc/core-win32-ia32-msvc/node_modules/@swc/wasm": {
+            "version": "1.2.130",
+            "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+            "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+            "dev": true,
+            "optional": true
+        },
+        "node_modules/@swc/core-win32-x64-msvc": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.2.224.tgz",
+            "integrity": "sha512-xALNoKi/UAQ2NflIkCBaZ4Nib75a4YwFp2pZ5Yen3vR8hxK2UJYlaNwyfsBwWfMOMsNxQ1Q1aaqoo0L+XON53Q==",
+            "cpu": [
+                "x64"
+            ],
+            "dev": true,
+            "optional": true,
+            "os": [
+                "win32"
+            ],
+            "engines": {
+                "node": ">=10"
+            }
+        },
+        "node_modules/@swc/wasm": {
+            "version": "1.2.122",
+            "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.122.tgz",
+            "integrity": "sha512-sM1VCWQxmNhFtdxME+8UXNyPNhxNu7zdb6ikWpz0YKAQQFRGT5ThZgJrubEpah335SUToNg8pkdDF7ibVCjxbQ==",
+            "dev": true,
+            "optional": true
+        },
         "node_modules/@szmarczak/http-timer": {
             "version": "1.1.2",
             "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-1.1.2.tgz",
                 "node": ">=8"
             }
         },
+        "node_modules/joycon": {
+            "version": "3.1.1",
+            "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz",
+            "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==",
+            "dev": true,
+            "engines": {
+                "node": ">=10"
+            }
+        },
         "node_modules/js-cleanup": {
             "version": "1.2.0",
             "resolved": "https://registry.npmjs.org/js-cleanup/-/js-cleanup-1.2.0.tgz",
                 "semver": "bin/semver.js"
             }
         },
+        "node_modules/rollup-plugin-swc3": {
+            "version": "0.3.0",
+            "resolved": "https://registry.npmjs.org/rollup-plugin-swc3/-/rollup-plugin-swc3-0.3.0.tgz",
+            "integrity": "sha512-ZQK2XxYxSspmT8j6/Y4CaxRxAlZHbNnxI+m+yJ5I87ZLp5uH7CYL4hFlJk1jkcZ+Q2QC19jIg7AClB/7+XFljw==",
+            "dev": true,
+            "dependencies": {
+                "@rollup/pluginutils": "^4.2.1",
+                "deepmerge": "^4.2.2",
+                "joycon": "^3.1.1",
+                "jsonc-parser": "^3.0.0",
+                "typedoc": "^0.22.15"
+            },
+            "engines": {
+                "node": ">=12"
+            },
+            "peerDependencies": {
+                "@swc/core": ">=1.2.165",
+                "rollup": "^2.0.0"
+            }
+        },
+        "node_modules/rollup-plugin-swc3/node_modules/@rollup/pluginutils": {
+            "version": "4.2.1",
+            "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz",
+            "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==",
+            "dev": true,
+            "dependencies": {
+                "estree-walker": "^2.0.1",
+                "picomatch": "^2.2.2"
+            },
+            "engines": {
+                "node": ">= 8.0.0"
+            }
+        },
+        "node_modules/rollup-plugin-swc3/node_modules/brace-expansion": {
+            "version": "2.0.1",
+            "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
+            "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
+            "dev": true,
+            "dependencies": {
+                "balanced-match": "^1.0.0"
+            }
+        },
+        "node_modules/rollup-plugin-swc3/node_modules/glob": {
+            "version": "8.0.3",
+            "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz",
+            "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==",
+            "dev": true,
+            "dependencies": {
+                "fs.realpath": "^1.0.0",
+                "inflight": "^1.0.4",
+                "inherits": "2",
+                "minimatch": "^5.0.1",
+                "once": "^1.3.0"
+            },
+            "engines": {
+                "node": ">=12"
+            },
+            "funding": {
+                "url": "https://github.com/sponsors/isaacs"
+            }
+        },
+        "node_modules/rollup-plugin-swc3/node_modules/minimatch": {
+            "version": "5.1.0",
+            "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz",
+            "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==",
+            "dev": true,
+            "dependencies": {
+                "brace-expansion": "^2.0.1"
+            },
+            "engines": {
+                "node": ">=10"
+            }
+        },
+        "node_modules/rollup-plugin-swc3/node_modules/typedoc": {
+            "version": "0.22.18",
+            "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.18.tgz",
+            "integrity": "sha512-NK9RlLhRUGMvc6Rw5USEYgT4DVAUFk7IF7Q6MYfpJ88KnTZP7EneEa4RcP+tX1auAcz7QT1Iy0bUSZBYYHdoyA==",
+            "dev": true,
+            "dependencies": {
+                "glob": "^8.0.3",
+                "lunr": "^2.3.9",
+                "marked": "^4.0.16",
+                "minimatch": "^5.1.0",
+                "shiki": "^0.10.1"
+            },
+            "bin": {
+                "typedoc": "bin/typedoc"
+            },
+            "engines": {
+                "node": ">= 12.10.0"
+            },
+            "peerDependencies": {
+                "typescript": "4.0.x || 4.1.x || 4.2.x || 4.3.x || 4.4.x || 4.5.x || 4.6.x || 4.7.x"
+            }
+        },
         "node_modules/rollup-plugin-terser": {
             "version": "7.0.2",
             "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz",
                 }
             }
         },
+        "@swc/core": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.2.224.tgz",
+            "integrity": "sha512-K0B0QKT0eSpPlL4amWJzllYJigQdE7+ha6VQVks6g/oiko1yMYP8lGcCKOKb+KuvW1ltPzlyFqi7h7ryEVG2vQ==",
+            "dev": true,
+            "requires": {
+                "@swc/core-android-arm-eabi": "1.2.224",
+                "@swc/core-android-arm64": "1.2.224",
+                "@swc/core-darwin-arm64": "1.2.224",
+                "@swc/core-darwin-x64": "1.2.224",
+                "@swc/core-freebsd-x64": "1.2.224",
+                "@swc/core-linux-arm-gnueabihf": "1.2.224",
+                "@swc/core-linux-arm64-gnu": "1.2.224",
+                "@swc/core-linux-arm64-musl": "1.2.224",
+                "@swc/core-linux-x64-gnu": "1.2.224",
+                "@swc/core-linux-x64-musl": "1.2.224",
+                "@swc/core-win32-arm64-msvc": "1.2.224",
+                "@swc/core-win32-ia32-msvc": "1.2.224",
+                "@swc/core-win32-x64-msvc": "1.2.224"
+            }
+        },
+        "@swc/core-android-arm-eabi": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-android-arm-eabi/-/core-android-arm-eabi-1.2.224.tgz",
+            "integrity": "sha512-viVOYrhSqNxdDOCNu2UUfiAK0qjkmk/fB9mObdSb+48JlHv4kYBnSLjaIhj0NlXCsxgetH7QFbjrKXRJ+gpHqw==",
+            "dev": true,
+            "optional": true,
+            "requires": {
+                "@swc/wasm": "1.2.122"
+            }
+        },
+        "@swc/core-android-arm64": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-android-arm64/-/core-android-arm64-1.2.224.tgz",
+            "integrity": "sha512-HCfdnVyslhMX25BDOqE7rOcl3a6QHs34O3xLLY2J/wg2ICtbxehpbpBPrp+VBG3Ngv7VGD9OPhmFgGxElFtZLQ==",
+            "dev": true,
+            "optional": true,
+            "requires": {
+                "@swc/wasm": "1.2.130"
+            },
+            "dependencies": {
+                "@swc/wasm": {
+                    "version": "1.2.130",
+                    "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+                    "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+                    "dev": true,
+                    "optional": true
+                }
+            }
+        },
+        "@swc/core-darwin-arm64": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.2.224.tgz",
+            "integrity": "sha512-jzv8Eop0GDe4owRDWr02n/xT7Bm6eTFWoM3nFXOM865gNYfASGGm3HHm4z20yndIxq5xuKHcOOH9QXQQhe/lQA==",
+            "dev": true,
+            "optional": true
+        },
+        "@swc/core-darwin-x64": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.2.224.tgz",
+            "integrity": "sha512-hpdJt/BJ45+hcgs461nJxgMJVNN/2uJL8TLvFxeOJiDpF4r1elRxYfDC1W8ctMWB3eB3Wepz3Ku2z8l9UgPnyQ==",
+            "dev": true,
+            "optional": true
+        },
+        "@swc/core-freebsd-x64": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-freebsd-x64/-/core-freebsd-x64-1.2.224.tgz",
+            "integrity": "sha512-bVIXwwjYA1ZdMKTwrAosxG808nQqvHhzs/fOKUrl1VeZ9CTHA0FzpSXwaBf1shbUVKvQVPKydY0K5q9dkSUkpw==",
+            "dev": true,
+            "optional": true,
+            "requires": {
+                "@swc/wasm": "1.2.130"
+            },
+            "dependencies": {
+                "@swc/wasm": {
+                    "version": "1.2.130",
+                    "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+                    "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+                    "dev": true,
+                    "optional": true
+                }
+            }
+        },
+        "@swc/core-linux-arm-gnueabihf": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.2.224.tgz",
+            "integrity": "sha512-MY3UQI3IOjME5TpuIhwI0lqKHsU3x7BwlU4n/mLNe2lH3DLaP0rrGHCMI2iJqfiYKU1Rg1r01HXmysuiriF1TA==",
+            "dev": true,
+            "optional": true,
+            "requires": {
+                "@swc/wasm": "1.2.130"
+            },
+            "dependencies": {
+                "@swc/wasm": {
+                    "version": "1.2.130",
+                    "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+                    "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+                    "dev": true,
+                    "optional": true
+                }
+            }
+        },
+        "@swc/core-linux-arm64-gnu": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.2.224.tgz",
+            "integrity": "sha512-tEpaGq4wp79tR+4s0h8xbzcxW6tZOfb2/Jf1vrmRYfRBqryBRTdtn14Rfy4qlK3s/SC3NfI2MKxZRgcGnMCeWw==",
+            "dev": true,
+            "optional": true
+        },
+        "@swc/core-linux-arm64-musl": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.2.224.tgz",
+            "integrity": "sha512-jnrYqXc7aRzBnEqEp3nAi9tjuUhBnN0pSKiHJytlBP1QkXnH7HD44Da9udmKUFYB5hHpwaXE0NIh7jK0nSMnhw==",
+            "dev": true,
+            "optional": true
+        },
+        "@swc/core-linux-x64-gnu": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.2.224.tgz",
+            "integrity": "sha512-UBkeDlG+PrIXDH1sR4EIXN5qK4a677IHb6RBghbvBDJS61X9/nTDxtCF7/zCqDxJRahhUrT6lDsYpuLCws2hiw==",
+            "dev": true,
+            "optional": true
+        },
+        "@swc/core-linux-x64-musl": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.2.224.tgz",
+            "integrity": "sha512-CQMGDzxKvkzf6TOdaWnmhb6uk1XEhM/mM3BDfX+hx9j3Hg3bFw9qmPvrkoWI2G8J50MvpoR1iPBYyG2LNeQWeg==",
+            "dev": true,
+            "optional": true
+        },
+        "@swc/core-win32-arm64-msvc": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.2.224.tgz",
+            "integrity": "sha512-03V4apubsOhLKQNmfWGlgvDCJkhlh0ZOHcGddxb7bD4PeP6U0lnABG3hlz2uicwcIGBPu/p7jtm5/hezeiXE6Q==",
+            "dev": true,
+            "optional": true,
+            "requires": {
+                "@swc/wasm": "1.2.130"
+            },
+            "dependencies": {
+                "@swc/wasm": {
+                    "version": "1.2.130",
+                    "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+                    "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+                    "dev": true,
+                    "optional": true
+                }
+            }
+        },
+        "@swc/core-win32-ia32-msvc": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.2.224.tgz",
+            "integrity": "sha512-gPOmIdhCwkb5BbDiPs/4t1LIElFLoQwiv45XwK5wADh1qzLD3A8EtpnpXfLsjL/fUMlLIGCgHQ6BQ0x04VrI1Q==",
+            "dev": true,
+            "optional": true,
+            "requires": {
+                "@swc/wasm": "1.2.130"
+            },
+            "dependencies": {
+                "@swc/wasm": {
+                    "version": "1.2.130",
+                    "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.130.tgz",
+                    "integrity": "sha512-rNcJsBxS70+pv8YUWwf5fRlWX6JoY/HJc25HD/F8m6Kv7XhJdqPPMhyX6TKkUBPAG7TWlZYoxa+rHAjPy4Cj3Q==",
+                    "dev": true,
+                    "optional": true
+                }
+            }
+        },
+        "@swc/core-win32-x64-msvc": {
+            "version": "1.2.224",
+            "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.2.224.tgz",
+            "integrity": "sha512-xALNoKi/UAQ2NflIkCBaZ4Nib75a4YwFp2pZ5Yen3vR8hxK2UJYlaNwyfsBwWfMOMsNxQ1Q1aaqoo0L+XON53Q==",
+            "dev": true,
+            "optional": true
+        },
+        "@swc/wasm": {
+            "version": "1.2.122",
+            "resolved": "https://registry.npmjs.org/@swc/wasm/-/wasm-1.2.122.tgz",
+            "integrity": "sha512-sM1VCWQxmNhFtdxME+8UXNyPNhxNu7zdb6ikWpz0YKAQQFRGT5ThZgJrubEpah335SUToNg8pkdDF7ibVCjxbQ==",
+            "dev": true,
+            "optional": true
+        },
         "@szmarczak/http-timer": {
             "version": "1.1.2",
             "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-1.1.2.tgz",
                 }
             }
         },
+        "joycon": {
+            "version": "3.1.1",
+            "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz",
+            "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==",
+            "dev": true
+        },
         "js-cleanup": {
             "version": "1.2.0",
             "resolved": "https://registry.npmjs.org/js-cleanup/-/js-cleanup-1.2.0.tgz",
                 }
             }
         },
+        "rollup-plugin-swc3": {
+            "version": "0.3.0",
+            "resolved": "https://registry.npmjs.org/rollup-plugin-swc3/-/rollup-plugin-swc3-0.3.0.tgz",
+            "integrity": "sha512-ZQK2XxYxSspmT8j6/Y4CaxRxAlZHbNnxI+m+yJ5I87ZLp5uH7CYL4hFlJk1jkcZ+Q2QC19jIg7AClB/7+XFljw==",
+            "dev": true,
+            "requires": {
+                "@rollup/pluginutils": "^4.2.1",
+                "deepmerge": "^4.2.2",
+                "joycon": "^3.1.1",
+                "jsonc-parser": "^3.0.0",
+                "typedoc": "^0.22.15"
+            },
+            "dependencies": {
+                "@rollup/pluginutils": {
+                    "version": "4.2.1",
+                    "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz",
+                    "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==",
+                    "dev": true,
+                    "requires": {
+                        "estree-walker": "^2.0.1",
+                        "picomatch": "^2.2.2"
+                    }
+                },
+                "brace-expansion": {
+                    "version": "2.0.1",
+                    "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
+                    "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
+                    "dev": true,
+                    "requires": {
+                        "balanced-match": "^1.0.0"
+                    }
+                },
+                "glob": {
+                    "version": "8.0.3",
+                    "resolved": "https://registry.npmjs.org/glob/-/glob-8.0.3.tgz",
+                    "integrity": "sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==",
+                    "dev": true,
+                    "requires": {
+                        "fs.realpath": "^1.0.0",
+                        "inflight": "^1.0.4",
+                        "inherits": "2",
+                        "minimatch": "^5.0.1",
+                        "once": "^1.3.0"
+                    }
+                },
+                "minimatch": {
+                    "version": "5.1.0",
+                    "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz",
+                    "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==",
+                    "dev": true,
+                    "requires": {
+                        "brace-expansion": "^2.0.1"
+                    }
+                },
+                "typedoc": {
+                    "version": "0.22.18",
+                    "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.18.tgz",
+                    "integrity": "sha512-NK9RlLhRUGMvc6Rw5USEYgT4DVAUFk7IF7Q6MYfpJ88KnTZP7EneEa4RcP+tX1auAcz7QT1Iy0bUSZBYYHdoyA==",
+                    "dev": true,
+                    "requires": {
+                        "glob": "^8.0.3",
+                        "lunr": "^2.3.9",
+                        "marked": "^4.0.16",
+                        "minimatch": "^5.1.0",
+                        "shiki": "^0.10.1"
+                    }
+                }
+            }
+        },
         "rollup-plugin-terser": {
             "version": "7.0.2",
             "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz",
index 52559702a8b01ec688e21572009a8605d8984f2f..e983352bdd3eea4f795ace3b256b8f60d5b13619 100644 (file)
@@ -9,15 +9,15 @@
         "./auto/auto.js",
         "./dist/chart.umd.js"
     ],
-    "jsdelivr": "dist/chart.umd.js",
-    "unpkg": "dist/chart.umd.js",
-    "main": "dist/chart.js",
+    "jsdelivr": "./dist/chart.umd.js",
+    "unpkg": "./dist/chart.umd.js",
+    "main": "./dist/chart.js",
     "exports": {
         ".": "./dist/chart.js",
         "./auto": "./auto/auto.js",
         "./helpers": "./helpers/helpers.js"
     },
-    "types": "types/index.d.ts",
+    "types": "./dist/types.d.ts",
     "keywords": [
         "canvas",
         "charts",
     ],
     "scripts": {
         "autobuild": "rollup -c -w",
-        "build": "rollup -c",
+        "emitDeclarations": "tsc --emitDeclarationOnly",
+        "build": "rollup -c && npm run emitDeclarations",
         "dev": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers chrome --grep",
         "dev:ff": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers firefox --grep",
         "docs": "npm run build && vuepress build docs --no-cache",
         "docs:dev": "npm run build && vuepress dev docs --no-cache",
-        "lint-js": "eslint \"src/**/*.js\" \"test/**/*.js\" \"docs/**/*.js\"",
+        "lint-js": "eslint \"src/**/*.{js,ts}\" \"test/**/*.js\" \"docs/**/*.js\"",
         "lint-md": "eslint \"**/*.md\"",
-        "lint-tsc": "tsc",
         "lint-types": "eslint \"types/**/*.ts\" && npm run build && node types/tests/autogen.js && tsc -p types/tests/",
         "lint": "concurrently \"npm:lint-*\"",
         "test-size": "size-limit",
@@ -65,6 +65,7 @@
         "@rollup/plugin-node-resolve": "^13.3.0",
         "@simonbrunel/vuepress-plugin-versions": "^0.2.0",
         "@size-limit/preset-big-lib": "^8.0.0",
+        "@swc/core": "^1.2.224",
         "@types/estree": "^1.0.0",
         "@types/offscreencanvas": "^2019.7.0",
         "@typescript-eslint/eslint-plugin": "^5.32.0",
         "rollup": "^2.77.2",
         "rollup-plugin-cleanup": "^3.2.1",
         "rollup-plugin-istanbul": "^3.0.0",
+        "rollup-plugin-swc3": "^0.3.0",
         "rollup-plugin-terser": "^7.0.2",
         "size-limit": "^8.0.0",
         "typedoc": "^0.23.10",
index 9741212607d7a3f39f1643da68a4b437165c7ff8..b6ab1e82697ca92eb156ce417c0e91cebf1fab48 100644 (file)
@@ -1,8 +1,9 @@
 import cleanup from 'rollup-plugin-cleanup';
 import json from '@rollup/plugin-json';
 import resolve from '@rollup/plugin-node-resolve';
+import {swc} from 'rollup-plugin-swc3';
 import {terser} from 'rollup-plugin-terser';
-import { readFileSync } from "fs";
+import {readFileSync} from 'fs';
 
 const {version, homepage} = JSON.parse(readFileSync('./package.json'));
 
@@ -12,21 +13,42 @@ const banner = `/*!
  * (c) ${(new Date(process.env.SOURCE_DATE_EPOCH ? (process.env.SOURCE_DATE_EPOCH * 1000) : new Date().getTime())).getFullYear()} Chart.js Contributors
  * Released under the MIT License
  */`;
+const extensions = ['.js', '.ts'];
+const plugins = (minify) =>
+  [
+    json(),
+    resolve({
+      extensions
+    }),
+    swc({
+      jsc: {
+        parser: {
+          syntax: 'typescript'
+        },
+        target: 'es2022'
+      },
+      module: {
+        type: 'es6'
+      },
+      sourceMaps: true
+    }),
+    minify
+      ? terser({
+        output: {
+          preamble: banner
+        }
+      })
+      : cleanup({
+        comments: ['some', /__PURE__/]
+      })
+  ];
 
 export default [
   // UMD build
   // dist/chart.umd.js
   {
-    input: 'src/index.umd.js',
-    plugins: [
-      json(),
-      resolve(),
-      terser({
-        output: {
-          preamble: banner
-        }
-      }),
-    ],
+    input: 'src/index.umd.ts',
+    plugins: plugins(true),
     output: {
       name: 'Chart',
       file: 'dist/chart.umd.js',
@@ -41,16 +63,10 @@ export default [
   // helpers/*.js
   {
     input: {
-      'dist/chart': 'src/index.js',
-      'dist/helpers': 'src/helpers/index.js'
+      'dist/chart': 'src/index.ts',
+      'dist/helpers': 'src/helpers/index.ts'
     },
-    plugins: [
-      json(),
-      resolve(),
-      cleanup({
-        comments: ['some', /__PURE__/],
-      }),
-    ],
+    plugins: plugins(),
     output: {
       dir: './',
       chunkFileNames: 'dist/chunks/[name].js',
diff --git a/src/core/core.adapters.js b/src/core/core.adapters.js
deleted file mode 100644 (file)
index 0859ea0..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- * @namespace Chart._adapters
- * @since 2.8.0
- * @private
- */
-
-/**
- * @typedef { import("../../types").ChartOptions } ChartOptions
- */
-
-/**
- * @return {*}
- */
-function abstract() {
-  throw new Error('This method is not implemented: Check that a complete date adapter is provided.');
-}
-
-/**
- * Date adapter (current used by the time scale)
- * @namespace Chart._adapters._date
- * @memberof Chart._adapters
- * @private
- */
-
-/**
- * Currently supported unit string values.
- * @typedef {('millisecond'|'second'|'minute'|'hour'|'day'|'week'|'month'|'quarter'|'year')} Unit
- * @memberof Chart._adapters._date
- */
-
-export class DateAdapter {
-
-  static override(members) {
-    Object.assign(DateAdapter.prototype, members);
-  }
-
-  constructor(options) {
-    this.options = options || {};
-  }
-
-  /**
-   * Will called with chart options after adapter creation.
-   * @param {ChartOptions} chartOptions
-   */
-  // eslint-disable-next-line no-unused-vars
-  init(chartOptions) {}
-
-  /**
-        * Returns a map of time formats for the supported formatting units defined
-        * in Unit as well as 'datetime' representing a detailed date/time string.
-        * @returns {{string: string}}
-        */
-  formats() {
-    return abstract();
-  }
-
-  /**
-        * Parses the given `value` and return the associated timestamp.
-        * @param {any} value - the value to parse (usually comes from the data)
-        * @param {string} [format] - the expected data format
-        * @returns {(number|null)}
-        */
-  parse(value, format) { // eslint-disable-line no-unused-vars
-    return abstract();
-  }
-
-  /**
-        * Returns the formatted date in the specified `format` for a given `timestamp`.
-        * @param {number} timestamp - the timestamp to format
-        * @param {string} format - the date/time token
-        * @return {string}
-        */
-  format(timestamp, format) { // eslint-disable-line no-unused-vars
-    return abstract();
-  }
-
-  /**
-        * Adds the specified `amount` of `unit` to the given `timestamp`.
-        * @param {number} timestamp - the input timestamp
-        * @param {number} amount - the amount to add
-        * @param {Unit} unit - the unit as string
-        * @return {number}
-        */
-  add(timestamp, amount, unit) { // eslint-disable-line no-unused-vars
-    return abstract();
-  }
-
-  /**
-        * Returns the number of `unit` between the given timestamps.
-        * @param {number} a - the input timestamp (reference)
-        * @param {number} b - the timestamp to subtract
-        * @param {Unit} unit - the unit as string
-        * @return {number}
-        */
-  diff(a, b, unit) { // eslint-disable-line no-unused-vars
-    return abstract();
-  }
-
-  /**
-        * Returns start of `unit` for the given `timestamp`.
-        * @param {number} timestamp - the input timestamp
-        * @param {Unit|'isoWeek'} unit - the unit as string
-        * @param {number} [weekday] - the ISO day of the week with 1 being Monday
-        * and 7 being Sunday (only needed if param *unit* is `isoWeek`).
-        * @return {number}
-        */
-  startOf(timestamp, unit, weekday) { // eslint-disable-line no-unused-vars
-    return abstract();
-  }
-
-  /**
-        * Returns end of `unit` for the given `timestamp`.
-        * @param {number} timestamp - the input timestamp
-        * @param {Unit|'isoWeek'} unit - the unit as string
-        * @return {number}
-        */
-  endOf(timestamp, unit) { // eslint-disable-line no-unused-vars
-    return abstract();
-  }
-
-}
-
-export default {
-  _date: DateAdapter
-};
diff --git a/src/core/core.adapters.ts b/src/core/core.adapters.ts
new file mode 100644 (file)
index 0000000..6132b46
--- /dev/null
@@ -0,0 +1,133 @@
+/**
+ * @namespace Chart._adapters
+ * @since 2.8.0
+ * @private
+ */
+
+import type {AnyObject} from '../../types/basic';
+import type {ChartOptions} from '../../types';
+
+export type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
+
+export interface DateAdapter<T extends AnyObject = AnyObject> {
+  readonly options: T;
+  /**
+   * Will called with chart options after adapter creation.
+   */
+  init(this: DateAdapter<T>, chartOptions: ChartOptions): void;
+  /**
+   * Returns a map of time formats for the supported formatting units defined
+   * in Unit as well as 'datetime' representing a detailed date/time string.
+   */
+  formats(this: DateAdapter<T>): Record<string, string>;
+  /**
+   * Parses the given `value` and return the associated timestamp.
+   * @param value - the value to parse (usually comes from the data)
+   * @param [format] - the expected data format
+   */
+  parse(this: DateAdapter<T>, value: unknown, format?: TimeUnit): number | null;
+  /**
+   * Returns the formatted date in the specified `format` for a given `timestamp`.
+   * @param timestamp - the timestamp to format
+   * @param format - the date/time token
+   */
+  format(this: DateAdapter<T>, timestamp: number, format: TimeUnit): string;
+  /**
+   * Adds the specified `amount` of `unit` to the given `timestamp`.
+   * @param timestamp - the input timestamp
+   * @param amount - the amount to add
+   * @param unit - the unit as string
+   */
+  add(this: DateAdapter<T>, timestamp: number, amount: number, unit: TimeUnit): number;
+  /**
+   * Returns the number of `unit` between the given timestamps.
+   * @param a - the input timestamp (reference)
+   * @param b - the timestamp to subtract
+   * @param unit - the unit as string
+   */
+  diff(this: DateAdapter<T>, a: number, b: number, unit: TimeUnit): number;
+  /**
+   * Returns start of `unit` for the given `timestamp`.
+   * @param timestamp - the input timestamp
+   * @param unit - the unit as string
+   * @param [weekday] - the ISO day of the week with 1 being Monday
+   * and 7 being Sunday (only needed if param *unit* is `isoWeek`).
+   */
+  startOf(this: DateAdapter<T>, timestamp: number, unit: TimeUnit | 'isoWeek', weekday?: number): number;
+  /**
+   * Returns end of `unit` for the given `timestamp`.
+   * @param timestamp - the input timestamp
+   * @param unit - the unit as string
+   */
+  endOf(this: DateAdapter<T>, timestamp: number, unit: TimeUnit | 'isoWeek'): number;
+}
+
+function abstract<T = void>(): T {
+  throw new Error('This method is not implemented: Check that a complete date adapter is provided.');
+}
+
+/**
+ * Date adapter (current used by the time scale)
+ * @namespace Chart._adapters._date
+ * @memberof Chart._adapters
+ * @private
+ */
+class DateAdapterBase implements DateAdapter {
+
+  /**
+   * Override default date adapter methods.
+   * Accepts type parameter to define options type.
+   * @example
+   * Chart._adapters._date.override<{myAdapterOption: string}>({
+   *   init() {
+   *     console.log(this.options.myAdapterOption);
+   *   }
+   * })
+   */
+  static override<T extends AnyObject = AnyObject>(
+    members: Partial<Omit<DateAdapter<T>, 'options'>>
+  ) {
+    Object.assign(DateAdapterBase.prototype, members);
+  }
+
+  readonly options: AnyObject;
+
+  constructor(options: AnyObject) {
+    this.options = options || {};
+  }
+
+  // eslint-disable-next-line @typescript-eslint/no-empty-function
+  init() {}
+
+  formats(): Record<string, string> {
+    return abstract();
+  }
+
+  parse(): number | null {
+    return abstract();
+  }
+
+  format(): string {
+    return abstract();
+  }
+
+  add(): number {
+    return abstract();
+  }
+
+  diff(): number {
+    return abstract();
+  }
+
+  startOf(): number {
+    return abstract();
+  }
+
+  endOf(): number {
+    return abstract();
+  }
+}
+
+export default {
+  _date: DateAdapterBase
+};
diff --git a/src/core/core.element.js b/src/core/core.element.js
deleted file mode 100644 (file)
index d3fe490..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-import {isNumber} from '../helpers/helpers.math';
-
-export default class Element {
-
-  /**
-   * @type any
-   */
-  static defaults = {};
-
-  /**
-   * @type any
-   */
-  static defaultRoutes = undefined;
-
-  constructor() {
-    this.x = undefined;
-    this.y = undefined;
-    this.active = false;
-    this.options = undefined;
-    this.$animations = undefined;
-  }
-
-  /**
-        * @param {boolean} [useFinalPosition]
-        */
-  tooltipPosition(useFinalPosition) {
-    const {x, y} = this.getProps(['x', 'y'], useFinalPosition);
-    return {x, y};
-  }
-
-  hasValue() {
-    return isNumber(this.x) && isNumber(this.y);
-  }
-
-  /**
-        * Gets the current or final value of each prop. Can return extra properties (whole object).
-        * @param {string[]} props - properties to get
-        * @param {boolean} [final] - get the final value (animation target)
-        * @return {object}
-        */
-  getProps(props, final) {
-    const anims = this.$animations;
-    if (!final || !anims) {
-      // let's not create an object, if not needed
-      return this;
-    }
-    const ret = {};
-    props.forEach(prop => {
-      ret[prop] = anims[prop] && anims[prop].active() ? anims[prop]._to : this[prop];
-    });
-    return ret;
-  }
-}
diff --git a/src/core/core.element.ts b/src/core/core.element.ts
new file mode 100644 (file)
index 0000000..b42df08
--- /dev/null
@@ -0,0 +1,43 @@
+import type {AnyObject} from '../../types/basic';
+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> {
+
+  static defaults = {};
+  static defaultRoutes = undefined;
+
+  x: number;
+  y: number;
+  active = false;
+  options: O;
+  $animations: Record<keyof T, Animation>;
+
+  tooltipPosition(useFinalPosition: boolean): Point {
+    const {x, y} = this.getProps(['x', 'y'], useFinalPosition);
+    return {x, y} as Point;
+  }
+
+  hasValue() {
+    return isNumber(this.x) && isNumber(this.y);
+  }
+
+  /**
+   * Gets the current or final value of each prop. Can return extra properties (whole object).
+   * @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]> {
+    const anims = this.$animations;
+    if (!final || !anims) {
+      // let's not create an object, if not needed
+      return this as Pick<T, P[number]>;
+    }
+    const ret: Partial<Pick<T, P[number]>> = {};
+    props.forEach((prop) => {
+      ret[prop] = anims[prop] && anims[prop].active() ? anims[prop]._to : this[prop as string];
+    });
+    return ret as Pick<T, P[number]>;
+  }
+}
index f054ef66a2057ace1759e50fe5999db079b3f1ea..333a7306e8ce955e79c66127fdb0229fdd469eca 100644 (file)
@@ -14,7 +14,7 @@ const formatters = {
    * @return {string|string[]} the label to display
    */
   values(value) {
-    return isArray(value) ? value : '' + value;
+    return isArray(value) ? /** @type {string[]} */ (value) : '' + value;
   },
 
   /**
similarity index 92%
rename from src/core/index.js
rename to src/core/index.ts
index af0b30963fcad44aab1ec7c94218790d3e5fe4db..706884b05777b1ccc9fe1f65759daa52a40e3d23 100644 (file)
@@ -1,3 +1,4 @@
+export type {DateAdapter, TimeUnit} from './core.adapters';
 export {default as _adapters} from './core.adapters';
 export {default as Animation} from './core.animation';
 export {default as Animations} from './core.animations';
index f9327d72a676f47a950e7bdba6bbc945a03efbae..42ca16738b3b8ce7a4a89c4b3dab0ee834edc147 100644 (file)
@@ -3,6 +3,8 @@ import {_angleBetween, getAngleFromPoint, TAU, HALF_PI, valueOrDefault} from '..
 import {PI, _isBetween, _limitValue} from '../helpers/helpers.math';
 import {_readValueToProps} from '../helpers/helpers.options';
 
+/** @typedef {{ x: number, y: number, startAngle: number, endAngle: number, innerRadius: number, outerRadius: number, circumference: number }} ArcProps */
+
 function clipArc(ctx, element, endAngle) {
   const {startAngle, pixelMargin, x, y, outerRadius, innerRadius} = element;
   let angleMargin = pixelMargin / outerRadius;
@@ -310,13 +312,13 @@ export default class ArcElement extends Element {
   inRange(chartX, chartY, useFinalPosition) {
     const point = this.getProps(['x', 'y'], useFinalPosition);
     const {angle, distance} = getAngleFromPoint(point, {x: chartX, y: chartY});
-    const {startAngle, endAngle, innerRadius, outerRadius, circumference} = this.getProps([
+    const {startAngle, endAngle, innerRadius, outerRadius, circumference} = /** @type {ArcProps} */ (this.getProps([
       'startAngle',
       'endAngle',
       'innerRadius',
       'outerRadius',
       'circumference'
-    ], useFinalPosition);
+    ], useFinalPosition));
     const rAdjust = this.options.spacing / 2;
     const _circumference = valueOrDefault(circumference, endAngle - startAngle);
     const betweenAngles = _circumference >= TAU || _angleBetween(angle, startAngle, endAngle);
@@ -329,7 +331,7 @@ export default class ArcElement extends Element {
         * @param {boolean} [useFinalPosition]
         */
   getCenterPoint(useFinalPosition) {
-    const {x, y, startAngle, endAngle, innerRadius, outerRadius} = this.getProps([
+    const {x, y, startAngle, endAngle, innerRadius, outerRadius} = /** @type {ArcProps} */ (this.getProps([
       'x',
       'y',
       'startAngle',
@@ -337,7 +339,7 @@ export default class ArcElement extends Element {
       'innerRadius',
       'outerRadius',
       'circumference',
-    ], useFinalPosition);
+    ], useFinalPosition));
     const {offset, spacing} = this.options;
     const halfAngle = (startAngle + endAngle) / 2;
     const halfRadius = (innerRadius + outerRadius + spacing + offset) / 2;
index c70f2d84fc48cc48b51a13f59980ce950107e775..5f2f7515050e1c7eb1e10ee887396a3d05006977 100644 (file)
@@ -3,6 +3,8 @@ import {isObject, _isBetween, _limitValue} from '../helpers';
 import {addRoundedRectPath} from '../helpers/helpers.canvas';
 import {toTRBL, toTRBLCorners} from '../helpers/helpers.options';
 
+/** @typedef {{ x: number, y: number, base: number, horizontal: boolean, width: number, height: number }} BarProps */
+
 /**
  * Helper function to get the bounds of the bar regardless of the orientation
  * @param {BarElement} bar the bar
@@ -11,7 +13,7 @@ import {toTRBL, toTRBLCorners} from '../helpers/helpers.options';
  * @private
  */
 function getBarBounds(bar, useFinalPosition) {
-  const {x, y, base, width, height} = bar.getProps(['x', 'y', 'base', 'width', 'height'], useFinalPosition);
+  const {x, y, base, width, height} = /** @type {BarProps} */ (bar.getProps(['x', 'y', 'base', 'width', 'height'], useFinalPosition));
 
   let left, right, top, bottom, half;
 
@@ -211,7 +213,7 @@ export default class BarElement extends Element {
   }
 
   getCenterPoint(useFinalPosition) {
-    const {x, y, base, horizontal} = this.getProps(['x', 'y', 'base', 'horizontal'], useFinalPosition);
+    const {x, y, base, horizontal} = /** @type {BarProps} */ (this.getProps(['x', 'y', 'base', 'horizontal'], useFinalPosition));
     return {
       x: horizontal ? (x + base) / 2 : x,
       y: horizontal ? y : (y + base) / 2
index 8eb9f48ec7f394e7200fa3d0cbee86e6c7f47709..b651d65b19884ebfda9c1a8ecf430077db5d3781 100644 (file)
@@ -48,7 +48,7 @@ export default class PointElement extends Element {
 
   inRange(mouseX, mouseY, useFinalPosition) {
     const options = this.options;
-    const {x, y} = this.getProps(['x', 'y'], useFinalPosition);
+    const {x, y} = /** @type {{ x: number, y: number }} */ (this.getProps(['x', 'y'], useFinalPosition));
     return ((Math.pow(mouseX - x, 2) + Math.pow(mouseY - y, 2)) < Math.pow(options.hitRadius + options.radius, 2));
   }
 
similarity index 51%
rename from src/helpers/helpers.core.js
rename to src/helpers/helpers.core.ts
index 1b1d1ff78109ac2dd522361ba76bef4a14c31e38..304394c47a14e460295dde98b2c1ed4f82abcea6 100644 (file)
@@ -1,40 +1,40 @@
 /**
  * @namespace Chart.helpers
  */
+
+import type {AnyObject} from '../../types/basic';
+import type {ActiveDataPoint, ChartEvent} from '../../types';
+
 /**
  * An empty function that can be used, for example, for optional callback.
  */
-export function noop() {}
+export function noop() {
+  /* noop */
+}
 
 /**
  * Returns a unique id, sequentially generated from a global variable.
- * @returns {number}
- * @function
  */
-export const uid = (function() {
+export const uid = (() => {
   let id = 0;
-  return function() {
-    return id++;
-  };
-}());
+  return () => id++;
+})();
 
 /**
  * Returns true if `value` is neither null nor undefined, else returns false.
- * @param {*} value - The value to test.
- * @returns {boolean}
+ * @param value - The value to test.
  * @since 2.7.0
  */
-export function isNullOrUndef(value) {
+export function isNullOrUndef(value: unknown): value is null | undefined {
   return value === null || typeof value === 'undefined';
 }
 
 /**
  * Returns true if `value` is an array (including typed arrays), else returns false.
- * @param {*} value - The value to test.
- * @returns {boolean}
+ * @param value - The value to test.
  * @function
  */
-export function isArray(value) {
+export function isArray<T = unknown>(value: unknown): value is T[] {
   if (Array.isArray && Array.isArray(value)) {
     return true;
   }
@@ -47,50 +47,48 @@ export function isArray(value) {
 
 /**
  * Returns true if `value` is an object (excluding null), else returns false.
- * @param {*} value - The value to test.
- * @returns {boolean}
+ * @param value - The value to test.
  * @since 2.7.0
  */
-export function isObject(value) {
+export function isObject(value: unknown): value is AnyObject {
   return value !== null && Object.prototype.toString.call(value) === '[object Object]';
 }
 
 /**
  * Returns true if `value` is a finite number, else returns false
- * @param {*} value  - The value to test.
- * @returns {boolean}
+ * @param value  - The value to test.
  */
-const isNumberFinite = (value) => (typeof value === 'number' || value instanceof Number) && isFinite(+value);
+function isNumberFinite(value: unknown): value is number {
+  return (typeof value === 'number' || value instanceof Number) && isFinite(+value);
+}
 export {
   isNumberFinite as isFinite,
 };
 
 /**
  * Returns `value` if finite, else returns `defaultValue`.
- * @param {*} value - The value to return if defined.
- * @param {*} defaultValue - The value to return if `value` is not finite.
- * @returns {*}
+ * @param value - The value to return if defined.
+ * @param defaultValue - The value to return if `value` is not finite.
  */
-export function finiteOrDefault(value, defaultValue) {
+export function finiteOrDefault(value: unknown, defaultValue: number) {
   return isNumberFinite(value) ? value : defaultValue;
 }
 
 /**
  * Returns `value` if defined, else returns `defaultValue`.
- * @param {*} value - The value to return if defined.
- * @param {*} defaultValue - The value to return if `value` is undefined.
- * @returns {*}
+ * @param value - The value to return if defined.
+ * @param defaultValue - The value to return if `value` is undefined.
  */
-export function valueOrDefault(value, defaultValue) {
+export function valueOrDefault<T>(value: T | undefined, defaultValue: T) {
   return typeof value === 'undefined' ? defaultValue : value;
 }
 
-export const toPercentage = (value, dimension) =>
+export const toPercentage = (value: number | string, dimension: number) =>
   typeof value === 'string' && value.endsWith('%') ?
     parseFloat(value) / 100
-    : value / dimension;
+    : +value / dimension;
 
-export const toDimension = (value, dimension) =>
+export const toDimension = (value: number | string, dimension: number) =>
   typeof value === 'string' && value.endsWith('%') ?
     parseFloat(value) / 100 * dimension
     : +value;
@@ -98,12 +96,15 @@ export const toDimension = (value, dimension) =>
 /**
  * Calls `fn` with the given `args` in the scope defined by `thisArg` and returns the
  * value returned by `fn`. If `fn` is not a function, this method returns undefined.
- * @param {function} fn - The function to call.
- * @param {Array|undefined|null} args - The arguments with which `fn` should be called.
- * @param {object} [thisArg] - The value of `this` provided for the call to `fn`.
- * @returns {*}
+ * @param fn - The function to call.
+ * @param args - The arguments with which `fn` should be called.
+ * @param [thisArg] - The value of `this` provided for the call to `fn`.
  */
-export function callback(fn, args, thisArg) {
+export function callback<T extends (this: TA, ...restArgs: unknown[]) => R, TA, R>(
+  fn: T | undefined,
+  args: unknown[],
+  thisArg?: TA
+): R | undefined {
   if (fn && typeof fn.call === 'function') {
     return fn.apply(thisArg, args);
   }
@@ -113,13 +114,30 @@ export function callback(fn, args, thisArg) {
  * Note(SB) for performance sake, this method should only be used when loopable type
  * is unknown or in none intensive code (not called often and small loopable). Else
  * it's preferable to use a regular for() loop and save extra function calls.
- * @param {object|Array} loopable - The object or array to be iterated.
- * @param {function} fn - The function to call for each item.
- * @param {object} [thisArg] - The value of `this` provided for the call to `fn`.
- * @param {boolean} [reverse] - If true, iterates backward on the loopable.
+ * @param loopable - The object or array to be iterated.
+ * @param fn - The function to call for each item.
+ * @param [thisArg] - The value of `this` provided for the call to `fn`.
+ * @param [reverse] - If true, iterates backward on the loopable.
  */
-export function each(loopable, fn, thisArg, reverse) {
-  let i, len, keys;
+export function each<T, TA>(
+  loopable: Record<string, T>,
+  fn: (this: TA, v: T, i: string) => void,
+  thisArg?: TA,
+  reverse?: boolean
+): void;
+export function each<T, TA>(
+  loopable: T[],
+  fn: (this: TA, v: T, i: number) => void,
+  thisArg?: TA,
+  reverse?: boolean
+): void;
+export function each<T, TA>(
+  loopable: T[] | Record<string, T>,
+  fn: (this: TA, v: T, i: any) => void,
+  thisArg?: TA,
+  reverse?: boolean
+) {
+  let i: number, len: number, keys: string[];
   if (isArray(loopable)) {
     len = loopable.length;
     if (reverse) {
@@ -142,13 +160,12 @@ export function each(loopable, fn, thisArg, reverse) {
 
 /**
  * Returns true if the `a0` and `a1` arrays have the same content, else returns false.
- * @param {Array} a0 - The array to compare
- * @param {Array} a1 - The array to compare
- * @returns {boolean}
+ * @param a0 - The array to compare
+ * @param a1 - The array to compare
  * @private
  */
-export function _elementsEqual(a0, a1) {
-  let i, ilen, v0, v1;
+export function _elementsEqual(a0: ActiveDataPoint[], a1: ActiveDataPoint[]) {
+  let i: number, ilen: number, v0: ActiveDataPoint, v1: ActiveDataPoint;
 
   if (!a0 || !a1 || a0.length !== a1.length) {
     return false;
@@ -168,12 +185,11 @@ export function _elementsEqual(a0, a1) {
 
 /**
  * Returns a deep copy of `source` without keeping references on objects and arrays.
- * @param {*} source - The value to clone.
- * @returns {*}
+ * @param source - The value to clone.
  */
-export function clone(source) {
+export function clone<T>(source: T): T {
   if (isArray(source)) {
-    return source.map(clone);
+    return source.map(clone) as unknown as T;
   }
 
   if (isObject(source)) {
@@ -192,7 +208,7 @@ export function clone(source) {
   return source;
 }
 
-function isValidKey(key) {
+function isValidKey(key: string) {
   return ['__proto__', 'prototype', 'constructor'].indexOf(key) === -1;
 }
 
@@ -201,7 +217,7 @@ function isValidKey(key) {
  * Note(SB): also used by mergeConfig and mergeScaleConfig as fallback.
  * @private
  */
-export function _merger(key, target, source, options) {
+export function _merger(key: string, target: AnyObject, source: AnyObject, options: AnyObject) {
   if (!isValidKey(key)) {
     return;
   }
@@ -210,42 +226,58 @@ export function _merger(key, target, source, options) {
   const sval = source[key];
 
   if (isObject(tval) && isObject(sval)) {
-    // eslint-disable-next-line no-use-before-define
+    // eslint-disable-next-line @typescript-eslint/no-use-before-define
     merge(tval, sval, options);
   } else {
     target[key] = clone(sval);
   }
 }
 
+export interface MergeOptions {
+  merger?: (key: string, target: AnyObject, source: AnyObject, options?: AnyObject) => void;
+}
+
 /**
  * Recursively deep copies `source` properties into `target` with the given `options`.
  * IMPORTANT: `target` is not cloned and will be updated with `source` properties.
- * @param {object} target - The target object in which all sources are merged into.
- * @param {object|object[]} source - Object(s) to merge into `target`.
- * @param {object} [options] - Merging options:
- * @param {function} [options.merger] - The merge method (key, target, source, options)
- * @returns {object} The `target` object.
+ * @param target - The target object in which all sources are merged into.
+ * @param source - Object(s) to merge into `target`.
+ * @param [options] - Merging options:
+ * @param [options.merger] - The merge method (key, target, source, options)
+ * @returns The `target` object.
  */
-export function merge(target, source, options) {
+export function merge<T>(target: T, source: [], options?: MergeOptions): T;
+export function merge<T, S1>(target: T, source: S1, options?: MergeOptions): T & S1;
+export function merge<T, S1>(target: T, source: [S1], options?: MergeOptions): T & S1;
+export function merge<T, S1, S2>(target: T, source: [S1, S2], options?: MergeOptions): T & S1 & S2;
+export function merge<T, S1, S2, S3>(target: T, source: [S1, S2, S3], options?: MergeOptions): T & S1 & S2 & S3;
+export function merge<T, S1, S2, S3, S4>(
+  target: T,
+  source: [S1, S2, S3, S4],
+  options?: MergeOptions
+): T & S1 & S2 & S3 & S4;
+export function merge<T>(target: T, source: AnyObject[], options?: MergeOptions): AnyObject;
+export function merge<T>(target: T, source: AnyObject[], options?: MergeOptions): AnyObject {
   const sources = isArray(source) ? source : [source];
   const ilen = sources.length;
 
   if (!isObject(target)) {
-    return target;
+    return target as AnyObject;
   }
 
   options = options || {};
   const merger = options.merger || _merger;
+  let current: AnyObject;
 
   for (let i = 0; i < ilen; ++i) {
-    source = sources[i];
-    if (!isObject(source)) {
+    current = sources[i];
+    if (!isObject(current)) {
       continue;
     }
 
-    const keys = Object.keys(source);
+    const keys = Object.keys(current);
     for (let k = 0, klen = keys.length; k < klen; ++k) {
-      merger(keys[k], target, source, options);
+      merger(keys[k], target, current, options as AnyObject);
     }
   }
 
@@ -255,20 +287,27 @@ export function merge(target, source, options) {
 /**
  * Recursively deep copies `source` properties into `target` *only* if not defined in target.
  * IMPORTANT: `target` is not cloned and will be updated with `source` properties.
- * @param {object} target - The target object in which all sources are merged into.
- * @param {object|object[]} source - Object(s) to merge into `target`.
- * @returns {object} The `target` object.
+ * @param target - The target object in which all sources are merged into.
+ * @param source - Object(s) to merge into `target`.
+ * @returns The `target` object.
  */
-export function mergeIf(target, source) {
-  // eslint-disable-next-line no-use-before-define
-  return merge(target, source, {merger: _mergerIf});
+export function mergeIf<T>(target: T, source: []): T;
+export function mergeIf<T, S1>(target: T, source: S1): T & S1;
+export function mergeIf<T, S1>(target: T, source: [S1]): T & S1;
+export function mergeIf<T, S1, S2>(target: T, source: [S1, S2]): T & S1 & S2;
+export function mergeIf<T, S1, S2, S3>(target: T, source: [S1, S2, S3]): T & S1 & S2 & S3;
+export function mergeIf<T, S1, S2, S3, S4>(target: T, source: [S1, S2, S3, S4]): T & S1 & S2 & S3 & S4;
+export function mergeIf<T>(target: T, source: AnyObject[]): AnyObject;
+export function mergeIf<T>(target: T, source: AnyObject[]): AnyObject {
+  // eslint-disable-next-line @typescript-eslint/no-use-before-define
+  return merge<T>(target, source, {merger: _mergerIf});
 }
 
 /**
  * Merges source[key] in target[key] only if target[key] is undefined.
  * @private
  */
-export function _mergerIf(key, target, source) {
+export function _mergerIf(key: string, target: AnyObject, source: AnyObject) {
   if (!isValidKey(key)) {
     return;
   }
@@ -286,10 +325,10 @@ export function _mergerIf(key, target, source) {
 /**
  * @private
  */
-export function _deprecated(scope, value, previous, current) {
+export function _deprecated(scope: string, value: unknown, previous: string, current: string) {
   if (value !== undefined) {
     console.warn(scope + ': "' + previous +
-                       '" is deprecated. Please use "' + current + '" instead');
+      '" is deprecated. Please use "' + current + '" instead');
   }
 }
 
@@ -302,12 +341,26 @@ const keyResolvers = {
   y: o => o.y
 };
 
-export function resolveObjectKey(obj, key) {
-  const resolver = keyResolvers[key] || (keyResolvers[key] = _getKeyResolver(key));
-  return resolver(obj);
+/**
+ * @private
+ */
+export function _splitKey(key: string) {
+  const parts = key.split('.');
+  const keys: string[] = [];
+  let tmp = '';
+  for (const part of parts) {
+    tmp += part;
+    if (tmp.endsWith('\\')) {
+      tmp = tmp.slice(0, -1) + '.';
+    } else {
+      keys.push(tmp);
+      tmp = '';
+    }
+  }
+  return keys;
 }
 
-function _getKeyResolver(key) {
+function _getKeyResolver(key: string) {
   const keys = _splitKey(key);
   return obj => {
     for (const k of keys) {
@@ -322,39 +375,25 @@ function _getKeyResolver(key) {
   };
 }
 
-/**
- * @private
- */
-export function _splitKey(key) {
-  const parts = key.split('.');
-  const keys = [];
-  let tmp = '';
-  for (const part of parts) {
-    tmp += part;
-    if (tmp.endsWith('\\')) {
-      tmp = tmp.slice(0, -1) + '.';
-    } else {
-      keys.push(tmp);
-      tmp = '';
-    }
-  }
-  return keys;
+export function resolveObjectKey(obj: AnyObject, key: string): AnyObject {
+  const resolver = keyResolvers[key] || (keyResolvers[key] = _getKeyResolver(key));
+  return resolver(obj);
 }
 
 /**
  * @private
  */
-export function _capitalize(str) {
+export function _capitalize(str: string) {
   return str.charAt(0).toUpperCase() + str.slice(1);
 }
 
 
-export const defined = (value) => typeof value !== 'undefined';
+export const defined = (value: unknown) => typeof value !== 'undefined';
 
-export const isFunction = (value) => typeof value === 'function';
+export const isFunction = (value: unknown) => typeof value === 'function';
 
 // Adapted from https://stackoverflow.com/questions/31128855/comparing-ecma6-sets-for-equality#31129384
-export const setsEqual = (a, b) => {
+export const setsEqual = <T>(a: Set<T>, b: Set<T>) => {
   if (a.size !== b.size) {
     return false;
   }
@@ -369,10 +408,9 @@ export const setsEqual = (a, b) => {
 };
 
 /**
- * @param {import('../../types').ChartEvent} e - The event
- * @returns {boolean}
+ * @param e - The event
  * @private
  */
-export function _isClickEvent(e) {
+export function _isClickEvent(e: ChartEvent) {
   return e.type === 'mouseup' || e.type === 'click' || e.type === 'contextmenu';
 }
index 4c901c85d9ea0f85d469c4a9720afb74ec05a55b..67afade08e5e7cd709845b84f8d032f307dd78cd 100644 (file)
@@ -40,6 +40,10 @@ export function toLineHeight(value, size) {
 
 const numberOrZero = v => +v || 0;
 
+/**
+ * @param {any} value
+ * @param {string[] | Record<string, string>} props
+ */
 export function _readValueToProps(value, props) {
   const ret = {};
   const objProps = isObject(props);
similarity index 100%
rename from src/helpers/index.js
rename to src/helpers/index.ts
diff --git a/src/helpers/types.ts b/src/helpers/types.ts
new file mode 100644 (file)
index 0000000..55b6e31
--- /dev/null
@@ -0,0 +1,8 @@
+/**
+ * Temporary entry point of the types at the time of the transition.
+ * After transition done need to remove it in favor of index.ts
+ */
+
+// export * from '.';
+export * from './helpers.core';
+export * from '../../types/helpers';
similarity index 100%
rename from src/index.js
rename to src/index.ts
similarity index 93%
rename from src/index.umd.js
rename to src/index.umd.ts
index d3539015bf2ae5621a3163e5a3521adc5fb80293..98088228cb13dc720da3736ea24f6af4a6271aac 100644 (file)
@@ -1,3 +1,4 @@
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
 // @ts-nocheck
 
 /**
@@ -5,7 +6,7 @@
  */
 import Chart from './core/core.controller';
 
-import * as helpers from './helpers/index';
+import * as helpers from './helpers';
 import _adapters from './core/core.adapters';
 import Animation from './core/core.animation';
 import animator from './core/core.animator';
@@ -50,3 +51,4 @@ if (typeof window !== 'undefined') {
 }
 
 export default Chart;
+
index 70b740d7785c2d3197816ca9943536f7d1fcab3b..8277825c5c9e840d9a3c6a955ab3ef4ebae1753c 100644 (file)
@@ -44,6 +44,7 @@ export function _resolveTarget(sources, index, propagate) {
  * @param {number} count
  */
 export function _decodeFill(line, index, count) {
+  /** @type {string | {value: number}} */
   const fill = parseFillOption(line);
 
   if (isObject(fill)) {
index 29f6e05f102a15cfb5c38d43b4c34a4454ccb6e4..a6df147a4a6ceb25447c83b4085dda64210a5ae6 100644 (file)
@@ -11,6 +11,7 @@ import {createContext, drawPoint} from '../helpers';
  * @typedef { import("../platform/platform.base").Chart } Chart
  * @typedef { import("../../types").ChartEvent } ChartEvent
  * @typedef { import("../../types").ActiveElement } ActiveElement
+ * @typedef { import("../core/core.interaction").InteractionItem } InteractionItem
  */
 
 const positioners = {
@@ -1168,10 +1169,10 @@ export class Tooltip extends Element {
   /**
         * Helper for determining the active elements for event
         * @param {ChartEvent} e - The event to handle
-        * @param {Element[]} lastActive - Previously active elements
+        * @param {InteractionItem[]} lastActive - Previously active elements
         * @param {boolean} [replay] - This is a replayed event (from update)
         * @param {boolean} [inChartArea] - The event is inside chartArea
-        * @returns {Element[]} - Active elements
+        * @returns {InteractionItem[]} - Active elements
         * @private
         */
   _getActiveElements(e, lastActive, replay, inChartArea) {
index cbd230d0d081495c4b6f122055ef015dce817eef..d783231d6ecca9d2702a0e106ef1917adeaa8b9e 100644 (file)
@@ -5,8 +5,9 @@ import Scale from '../core/core.scale';
 import {_arrayUnique, _filterBetween, _lookup} from '../helpers/helpers.collection';
 
 /**
- * @typedef { import("../core/core.adapters").Unit } Unit
+ * @typedef { import("../core/core.adapters").TimeUnit } Unit
  * @typedef {{common: boolean, size: number, steps?: number}} Interval
+ * @typedef { import("../core/core.adapters").DateAdapter } DateAdapter
  */
 
 /**
@@ -58,7 +59,7 @@ function parse(scale, input) {
   // Only parse if its not a timestamp already
   if (!isFinite(value)) {
     value = typeof parser === 'string'
-      ? adapter.parse(value, parser)
+      ? adapter.parse(value, /** @type {Unit} */ (parser))
       : adapter.parse(value);
   }
 
@@ -264,6 +265,7 @@ export default class TimeScale extends Scale {
 
   init(scaleOpts, opts) {
     const time = scaleOpts.time || (scaleOpts.time = {});
+    /** @type {DateAdapter} */
     const adapter = this._adapter = new adapters._date(scaleOpts.adapters.date);
 
     adapter.init(opts);
diff --git a/src/types.ts b/src/types.ts
new file mode 100644 (file)
index 0000000..cf780e1
--- /dev/null
@@ -0,0 +1,50 @@
+/**
+ * Temporary entry point of the types at the time of the transition.
+ * After transition done need to remove it in favor of index.ts
+ */
+
+export * from '.';
+/**
+ * Explicitly re-exporting to resolve the ambiguity.
+ */
+export {
+  BarController,
+  BubbleController,
+  DoughnutController,
+  LineController,
+  PieController,
+  PolarAreaController,
+  RadarController,
+  ScatterController,
+  Animation,
+  Animations,
+  Chart,
+  DatasetController,
+  Interaction,
+  Scale,
+  Ticks,
+  defaults,
+  layouts,
+  registry,
+  ArcElement,
+  BarElement,
+  LineElement,
+  PointElement,
+  BasePlatform,
+  BasicPlatform,
+  DomPlatform,
+  Decimation,
+  Filler,
+  Legend,
+  SubTitle,
+  Title,
+  Tooltip,
+  CategoryScale,
+  LinearScale,
+  LogarithmicScale,
+  RadialLinearScale,
+  TimeScale,
+  TimeSeriesScale,
+  registerables
+} from '../types';
+export * from '../types';
index 9a2e9d66be332db40860487ac1b97d21bfe17d53..ad54c85ea40c1250e02d65b45f47860c8791cc84 100644 (file)
@@ -1,16 +1,31 @@
 {
   "compilerOptions": {
-    "target": "ES6",
-    "moduleResolution": "Node",
-    "allowSyntheticDefaultImports": true,
-    "allowJs": true,
-    "checkJs": true,
-    "noEmit": true,
+    /* Type Checking */
     "alwaysStrict": true,
     "strictBindCallApply": true,
     "strictFunctionTypes": true,
+    /* todo: uncomment after transition to TS */
+    // "noFallthroughCasesInSwitch": true,
+    // "noImplicitOverride": true,
+    // "noImplicitReturns": true,
+    // "noUnusedLocals": true,
+    // "noUnusedParameters": true,
+    /* Modules */
+    "moduleResolution": "Node",
     "types": ["offscreencanvas"],
-    "lib": ["es2018", "DOM"]
+    /* Emit */
+    "declaration": true,
+    "outDir": "dist",
+    /* JavaScript Support */
+    "allowJs": true,
+    "checkJs": true,
+    /* Interop Constraints */
+    "allowSyntheticDefaultImports": true,
+    /* Language and Environment */
+    "target": "ES6",
+    "lib": ["es2018", "DOM"],
+    /* Completeness */
+    "skipLibCheck": true
   },
   "typedocOptions": {
     "name": "Chart.js",
@@ -21,7 +36,7 @@
     "out": "./dist/docs/typedoc"
   },
   "include": [
-    "./src/**/*.js",
+    "./src/**/*",
     "./types"
   ],
   "exclude": [
index 14f736c75688e0f1ffb10a6cbcaf6673547bce63..ca79ca01047d129f61f70804d5fa0a42e0386742 100644 (file)
@@ -1,22 +1,4 @@
-parser: '@typescript-eslint/parser'
-
-plugins:
-  - '@typescript-eslint'
-
-extends:
-  - chartjs
-  - plugin:@typescript-eslint/recommended
-
 rules:
-  # Replace stock eslint rules with typescript-eslint equivalents for proper
-  # TypeScript support.
-  indent: "off"
-  "@typescript-eslint/indent": ["error", 2]
-  no-use-before-define: "off"
-  '@typescript-eslint/no-use-before-define': "error"
-  no-shadow: "off"
-  '@typescript-eslint/no-shadow': "error"
-
   # These rules were set to warning to make the linting pass initially,
   # without making any major changes to types.
   object-curly-spacing: ["warn", "always"]
diff --git a/types/adapters.d.ts b/types/adapters.d.ts
deleted file mode 100644 (file)
index 7e3e63c..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-import type { ChartOptions } from '.';
-
-export type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
-
-export interface DateAdapter {
-  // Override one or multiple of the methods to adjust to the logic of the current date library.
-  override(members: Partial<DateAdapter>): void;
-  readonly options: unknown;
-
-  /**
-   * Will called with chart options after adapter creation.
-   * @param {ChartOptions} chartOptions
-   */
-  init(chartOptions: ChartOptions): void;
-  /**
-   * Returns a map of time formats for the supported formatting units defined
-   * in Unit as well as 'datetime' representing a detailed date/time string.
-   * @returns {{string: string}}
-   */
-  formats(): { [key: string]: string };
-  /**
-   * Parses the given `value` and return the associated timestamp.
-   * @param {unknown} value - the value to parse (usually comes from the data)
-   * @param {string} [format] - the expected data format
-   */
-  parse(value: unknown, format?: TimeUnit): number | null;
-  /**
-   * Returns the formatted date in the specified `format` for a given `timestamp`.
-   * @param {number} timestamp - the timestamp to format
-   * @param {string} format - the date/time token
-   * @return {string}
-   */
-  format(timestamp: number, format: TimeUnit): string;
-  /**
-   * Adds the specified `amount` of `unit` to the given `timestamp`.
-   * @param {number} timestamp - the input timestamp
-   * @param {number} amount - the amount to add
-   * @param {Unit} unit - the unit as string
-   * @return {number}
-   */
-  add(timestamp: number, amount: number, unit: TimeUnit): number;
-  /**
-   * Returns the number of `unit` between the given timestamps.
-   * @param {number} a - the input timestamp (reference)
-   * @param {number} b - the timestamp to subtract
-   * @param {Unit} unit - the unit as string
-   * @return {number}
-   */
-  diff(a: number, b: number, unit: TimeUnit): number;
-  /**
-   * Returns start of `unit` for the given `timestamp`.
-   * @param {number} timestamp - the input timestamp
-   * @param {Unit|'isoWeek'} unit - the unit as string
-   * @param {number} [weekday] - the ISO day of the week with 1 being Monday
-   * and 7 being Sunday (only needed if param *unit* is `isoWeek`).
-   * @return {number}
-   */
-  startOf(timestamp: number, unit: TimeUnit | 'isoWeek', weekday?: number): number;
-  /**
-   * Returns end of `unit` for the given `timestamp`.
-   * @param {number} timestamp - the input timestamp
-   * @param {Unit|'isoWeek'} unit - the unit as string
-   * @return {number}
-   */
-  endOf(timestamp: number, unit: TimeUnit | 'isoWeek'): number;
-}
-
-export const _adapters: {
-  _date: DateAdapter;
-};
index 0aece8eae53bf6471f85082a72802df8c02b5b66..31d8d0b57043868d1cf2c09dbf5422f567b6a883 100644 (file)
@@ -1,12 +1,13 @@
 import { Chart } from '.';
 import { AnyObject } from './basic';
 
-export class Animation {
+export declare class Animation {
   constructor(cfg: AnyObject, target: AnyObject, prop: string, to?: unknown);
   active(): boolean;
   update(cfg: AnyObject, to: unknown, date: number): void;
   cancel(): void;
   tick(date: number): void;
+  readonly _to: unknown;
 }
 
 export interface AnimationEvent {
@@ -16,7 +17,7 @@ export interface AnimationEvent {
   currentStep: number;
 }
 
-export class Animator {
+export declare class Animator {
   listen(chart: Chart, event: 'complete' | 'progress', cb: (event: AnimationEvent) => void): void;
   add(chart: Chart, items: readonly Animation[]): void;
   has(chart: Chart): boolean;
@@ -26,7 +27,7 @@ export class Animator {
   remove(chart: Chart): boolean;
 }
 
-export class Animations {
+export declare class Animations {
   constructor(chart: Chart, animations: AnyObject);
   configure(animations: AnyObject): void;
   update(target: AnyObject, values: AnyObject): undefined | boolean;
diff --git a/types/element.d.ts b/types/element.d.ts
deleted file mode 100644 (file)
index 3b9359b..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-import { AnyObject } from './basic';
-import { Point } from './geometric';
-
-export interface Element<T = AnyObject, O = AnyObject> {
-  readonly x: number;
-  readonly y: number;
-  readonly active: boolean;
-  readonly options: O;
-
-  tooltipPosition(useFinalPosition?: boolean): Point;
-  hasValue(): boolean;
-  getProps<P extends (keyof T)[]>(props: P, final?: boolean): Pick<T, P[number]>;
-}
-export const Element: {
-  prototype: Element;
-  new <T = AnyObject, O = AnyObject>(): Element<T, O>;
-};
diff --git a/types/helpers/helpers.core.d.ts b/types/helpers/helpers.core.d.ts
deleted file mode 100644 (file)
index bc376da..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-import { AnyObject } from '../basic';
-
-/**
- * An empty function that can be used, for example, for optional callback.
- */
-export function noop(): void;
-
-/**
- * Returns a unique id, sequentially generated from a global variable.
- * @returns {number}
- * @function
- */
-export function uid(): number;
-/**
- * Returns true if `value` is neither null nor undefined, else returns false.
- * @param {*} value - The value to test.
- * @returns {boolean}
- * @since 2.7.0
- */
-export function isNullOrUndef(value: unknown): value is null | undefined;
-/**
- * Returns true if `value` is an array (including typed arrays), else returns false.
- * @param {*} value - The value to test.
- * @returns {boolean}
- * @function
- */
-export function isArray<T = unknown>(value: unknown): value is ArrayLike<T>;
-/**
- * Returns true if `value` is an object (excluding null), else returns false.
- * @param {*} value - The value to test.
- * @returns {boolean}
- * @since 2.7.0
- */
-export function isObject(value: unknown): value is AnyObject;
-/**
- * Returns true if `value` is a finite number, else returns false
- * @param {*} value - The value to test.
- * @returns {boolean}
- */
-export function isFinite(value: unknown): value is number;
-
-/**
- * Returns `value` if finite, else returns `defaultValue`.
- * @param {*} value - The value to return if defined.
- * @param {*} defaultValue - The value to return if `value` is not finite.
- * @returns {*}
- */
-export function finiteOrDefault(value: unknown, defaultValue: number): number;
-
-/**
- * Returns `value` if defined, else returns `defaultValue`.
- * @param {*} value - The value to return if defined.
- * @param {*} defaultValue - The value to return if `value` is undefined.
- * @returns {*}
- */
-export function valueOrDefault<T>(value: T | undefined, defaultValue: T): T;
-
-export function toPercentage(value: number | string, dimesion: number): number;
-export function toDimension(value: number | string, dimension: number): number;
-
-/**
- * Calls `fn` with the given `args` in the scope defined by `thisArg` and returns the
- * value returned by `fn`. If `fn` is not a function, this method returns undefined.
- * @param fn - The function to call.
- * @param args - The arguments with which `fn` should be called.
- * @param [thisArg] - The value of `this` provided for the call to `fn`.
- * @returns {*}
- */
-export function callback<T extends (this: TA, ...args: unknown[]) => R, TA, R>(
-  fn: T | undefined,
-  args: unknown[],
-  thisArg?: TA
-): R | undefined;
-
-/**
- * Note(SB) for performance sake, this method should only be used when loopable type
- * is unknown or in none intensive code (not called often and small loopable). Else
- * it's preferable to use a regular for() loop and save extra function calls.
- * @param loopable - The object or array to be iterated.
- * @param fn - The function to call for each item.
- * @param [thisArg] - The value of `this` provided for the call to `fn`.
- * @param [reverse] - If true, iterates backward on the loopable.
- */
-export function each<T, TA>(
-  loopable: T[],
-  fn: (this: TA, v: T, i: number) => void,
-  thisArg?: TA,
-  reverse?: boolean
-): void;
-/**
- * Note(SB) for performance sake, this method should only be used when loopable type
- * is unknown or in none intensive code (not called often and small loopable). Else
- * it's preferable to use a regular for() loop and save extra function calls.
- * @param loopable - The object or array to be iterated.
- * @param fn - The function to call for each item.
- * @param [thisArg] - The value of `this` provided for the call to `fn`.
- * @param [reverse] - If true, iterates backward on the loopable.
- */
-export function each<T, TA>(
-  loopable: { [key: string]: T },
-  fn: (this: TA, v: T, k: string) => void,
-  thisArg?: TA,
-  reverse?: boolean
-): void;
-
-/**
- * Returns a deep copy of `source` without keeping references on objects and arrays.
- * @param source - The value to clone.
- */
-export function clone<T>(source: T): T;
-
-export interface MergeOptions {
-  merger?: (key: string, target: AnyObject, source: AnyObject, options: AnyObject) => AnyObject;
-}
-/**
- * Recursively deep copies `source` properties into `target` with the given `options`.
- * IMPORTANT: `target` is not cloned and will be updated with `source` properties.
- * @param target - The target object in which all sources are merged into.
- * @param source - Object(s) to merge into `target`.
- * @param {object} [options] - Merging options:
- * @param {function} [options.merger] - The merge method (key, target, source, options)
- * @returns {object} The `target` object.
- */
-export function merge<T>(target: T, source: [], options?: MergeOptions): T;
-export function merge<T, S1>(target: T, source: S1, options?: MergeOptions): T & S1;
-export function merge<T, S1>(target: T, source: [S1], options?: MergeOptions): T & S1;
-export function merge<T, S1, S2>(target: T, source: [S1, S2], options?: MergeOptions): T & S1 & S2;
-export function merge<T, S1, S2, S3>(target: T, source: [S1, S2, S3], options?: MergeOptions): T & S1 & S2 & S3;
-export function merge<T, S1, S2, S3, S4>(
-  target: T,
-  source: [S1, S2, S3, S4],
-  options?: MergeOptions
-): T & S1 & S2 & S3 & S4;
-export function merge<T>(target: T, source: AnyObject[], options?: MergeOptions): AnyObject;
-
-/**
- * Recursively deep copies `source` properties into `target` *only* if not defined in target.
- * IMPORTANT: `target` is not cloned and will be updated with `source` properties.
- * @param target - The target object in which all sources are merged into.
- * @param source - Object(s) to merge into `target`.
- * @returns The `target` object.
- */
-export function mergeIf<T>(target: T, source: []): T;
-export function mergeIf<T, S1>(target: T, source: S1): T & S1;
-export function mergeIf<T, S1>(target: T, source: [S1]): T & S1;
-export function mergeIf<T, S1, S2>(target: T, source: [S1, S2]): T & S1 & S2;
-export function mergeIf<T, S1, S2, S3>(target: T, source: [S1, S2, S3]): T & S1 & S2 & S3;
-export function mergeIf<T, S1, S2, S3, S4>(target: T, source: [S1, S2, S3, S4]): T & S1 & S2 & S3 & S4;
-export function mergeIf<T>(target: T, source: AnyObject[]): AnyObject;
-
-export function resolveObjectKey(obj: AnyObject, key: string): AnyObject;
-
-export function defined(value: unknown): boolean;
-
-export function isFunction(value: unknown): boolean;
-
-export function setsEqual(a: Set<unknown>, b: Set<unknown>): boolean;
index 682a5d05abd503dee11fa597f6f51796708c2b4e..7fb2a387767b25d0a241cd5d420731e66573e8c3 100644 (file)
@@ -2,4 +2,4 @@ import { EasingFunction } from '..';
 
 export type EasingFunctionSignature = (t: number) => number;
 
-export const easingEffects: Record<EasingFunction, EasingFunctionSignature>;
+export declare const easingEffects: Record<EasingFunction, EasingFunctionSignature>;
index 013326924a7abc3a8e1109499fc8d66dfbd98713..9753a4d9764192e6094265e5264ad4d6e698dfff 100644 (file)
@@ -1,7 +1,6 @@
 export * from './helpers.canvas';
 export * from './helpers.collection';
 export * from './helpers.color';
-export * from './helpers.core';
 export * from './helpers.curve';
 export * from './helpers.dom';
 export * from './helpers.easing';
index 4daf093ba14a8f658b6b0d9275ebcaf08581b643..bb93f117c8917c750e95e2c0e8248189cd1b2ef9 100644 (file)
@@ -1,17 +1,15 @@
 import { DeepPartial, DistributiveArray, UnionToIntersection } from './utils';
 
-import { TimeUnit } from './adapters';
+import { TimeUnit } from '../src/core/core.adapters';
 import { AnimationEvent } from './animation';
 import { AnyObject, EmptyObject } from './basic';
 import { Color } from './color';
-import { Element } from './element';
+import Element from '../src/core/core.element';
 import { ChartArea, Padding, Point } from './geometric';
 import { LayoutItem, LayoutPosition } from './layout';
 
-export { DateAdapter, TimeUnit, _adapters } from './adapters';
 export { Animation, Animations, Animator, AnimationEvent } from './animation';
 export { Color } from './color';
-export { Element } from './element';
 export { ChartArea, Point } from './geometric';
 export { LayoutItem, LayoutPosition } from './layout';
 
@@ -149,7 +147,7 @@ export interface BarControllerChartOptions {
 }
 
 export type BarController = DatasetController
-export const BarController: ChartComponent & {
+export declare const BarController: ChartComponent & {
   prototype: BarController;
   new (chart: Chart, datasetIndex: number): BarController;
 };
@@ -167,7 +165,7 @@ export interface BubbleDataPoint extends Point {
 }
 
 export type BubbleController = DatasetController
-export const BubbleController: ChartComponent & {
+export declare const BubbleController: ChartComponent & {
   prototype: BubbleController;
   new (chart: Chart, datasetIndex: number): BubbleController;
 };
@@ -213,7 +211,7 @@ export interface LineControllerChartOptions {
 }
 
 export type LineController = DatasetController
-export const LineController: ChartComponent & {
+export declare const LineController: ChartComponent & {
   prototype: LineController;
   new (chart: Chart, datasetIndex: number): LineController;
 };
@@ -225,7 +223,7 @@ export interface ScatterDataPoint extends Point {}
 export type ScatterControllerChartOptions = LineControllerChartOptions;
 
 export type ScatterController = LineController
-export const ScatterController: ChartComponent & {
+export declare const ScatterController: ChartComponent & {
   prototype: ScatterController;
   new (chart: Chart, datasetIndex: number): ScatterController;
 };
@@ -333,7 +331,7 @@ export interface DoughnutController extends DatasetController {
   calculateCircumference(value: number): number;
 }
 
-export const DoughnutController: ChartComponent & {
+export declare const DoughnutController: ChartComponent & {
   prototype: DoughnutController;
   new (chart: Chart, datasetIndex: number): DoughnutController;
 };
@@ -350,7 +348,7 @@ export type PieDataPoint = DoughnutDataPoint;
 export type PieMetaExtensions = DoughnutMetaExtensions;
 
 export type PieController = DoughnutController
-export const PieController: ChartComponent & {
+export declare const PieController: ChartComponent & {
   prototype: PieController;
   new (chart: Chart, datasetIndex: number): PieController;
 };
@@ -378,7 +376,7 @@ export interface PolarAreaControllerChartOptions {
 export interface PolarAreaController extends DoughnutController {
   countVisibleElements(): number;
 }
-export const PolarAreaController: ChartComponent & {
+export declare const PolarAreaController: ChartComponent & {
   prototype: PolarAreaController;
   new (chart: Chart, datasetIndex: number): PolarAreaController;
 };
@@ -411,7 +409,7 @@ export interface RadarControllerDatasetOptions
 export type RadarControllerChartOptions = LineControllerChartOptions;
 
 export type RadarController = DatasetController
-export const RadarController: ChartComponent & {
+export declare const RadarController: ChartComponent & {
   prototype: RadarController;
   new (chart: Chart, datasetIndex: number): RadarController;
 };
@@ -540,7 +538,7 @@ export declare class Chart<
   static unregister(...items: ChartComponentLike[]): void;
 }
 
-export const registerables: readonly ChartComponentLike[];
+export declare const registerables: readonly ChartComponentLike[];
 
 export declare type ChartItem =
   | string
@@ -561,7 +559,7 @@ export declare enum UpdateModeEnum {
 
 export type UpdateMode = keyof typeof UpdateModeEnum;
 
-export class DatasetController<
+export declare class DatasetController<
   TType extends ChartType = ChartType,
   TElement extends Element = Element,
   TDatasetElement extends Element = Element,
@@ -689,7 +687,7 @@ export type Overrides = {
   ChartTypeRegistry[key]['chartOptions'];
 }
 
-export const defaults: Defaults;
+export declare const defaults: Defaults;
 export interface InteractionOptions {
   axis?: string;
   intersect?: boolean;
@@ -742,7 +740,7 @@ export interface InteractionModeMap {
 
 export type InteractionMode = keyof InteractionModeMap;
 
-export const Interaction: {
+export declare const Interaction: {
   modes: InteractionModeMap;
 
   /**
@@ -757,7 +755,7 @@ export const Interaction: {
   ): InteractionItem[];
 };
 
-export const layouts: {
+export declare const layouts: {
   /**
    * Register a box to a chart.
    * A box is simply a reference to an object that requires layout. eg. Scales, Legend, Title.
@@ -1119,7 +1117,7 @@ export interface Registry {
   getScale(id: string): Scale | undefined;
 }
 
-export const registry: Registry;
+export declare const registry: Registry;
 
 export interface Tick {
   value: number;
@@ -1336,7 +1334,7 @@ export interface ScriptableScalePointLabelContext {
 }
 
 
-export const Ticks: {
+export declare const Ticks: {
   formatters: {
     /**
      * Formatter for value labels
@@ -1743,7 +1741,7 @@ export interface ArcElement<T extends ArcProps = ArcProps, O extends ArcOptions
   extends Element<T, O>,
   VisualElement {}
 
-export const ArcElement: ChartComponent & {
+export declare const ArcElement: ChartComponent & {
   prototype: ArcElement;
   new (cfg: AnyObject): ArcElement;
 };
@@ -1833,7 +1831,7 @@ export interface LineElement<T extends LineProps = LineProps, O extends LineOpti
   path(ctx: CanvasRenderingContext2D): boolean;
 }
 
-export const LineElement: ChartComponent & {
+export declare const LineElement: ChartComponent & {
   prototype: LineElement;
   new (cfg: AnyObject): LineElement;
 };
@@ -1947,7 +1945,7 @@ export interface PointElement<T extends PointProps = PointProps, O extends Point
   readonly parsed: CartesianParsedData;
 }
 
-export const PointElement: ChartComponent & {
+export declare const PointElement: ChartComponent & {
   prototype: PointElement;
   new (cfg: AnyObject): PointElement;
 };
@@ -2007,7 +2005,7 @@ export interface BarElement<
   O extends BarOptions = BarOptions
 > extends Element<T, O>, VisualElement {}
 
-export const BarElement: ChartComponent & {
+export declare const BarElement: ChartComponent & {
   prototype: BarElement;
   new (cfg: AnyObject): BarElement;
 };
@@ -2023,7 +2021,7 @@ export type ElementChartOptions<TType extends ChartType = ChartType> = {
   elements: ElementOptionsByType<TType>
 };
 
-export class BasePlatform {
+export declare class BasePlatform {
   /**
    * Called at chart construction time, returns a context2d instance implementing
    * the [W3C Canvas 2D Context API standard]{@link https://www.w3.org/TR/2dcontext/}.
@@ -2080,12 +2078,12 @@ export class BasePlatform {
   updateConfig(config: ChartConfiguration | ChartConfigurationCustomTypesPerDataset): void;
 }
 
-export class BasicPlatform extends BasePlatform {}
-export class DomPlatform extends BasePlatform {}
+export declare class BasicPlatform extends BasePlatform {}
+export declare class DomPlatform extends BasePlatform {}
 
-export const Decimation: Plugin;
+export declare const Decimation: Plugin;
 
-export const enum DecimationAlgorithm {
+export declare const enum DecimationAlgorithm {
   lttb = 'lttb',
   minmax = 'min-max',
 }
@@ -2105,7 +2103,7 @@ interface MinMaxDecimationOptions extends BaseDecimationOptions {
 
 export type DecimationOptions = LttbDecimationOptions | MinMaxDecimationOptions;
 
-export const Filler: Plugin;
+export declare const Filler: Plugin;
 export interface FillerOptions {
   drawTime: 'beforeDatasetDraw' | 'beforeDatasetsDraw';
   propagate: boolean;
@@ -2135,7 +2133,7 @@ export interface FillerControllerDatasetOptions {
   fill: FillTarget | ComplexFillTarget;
 }
 
-export const Legend: Plugin;
+export declare const Legend: Plugin;
 
 export interface LegendItem {
   /**
@@ -2387,8 +2385,8 @@ export interface LegendOptions<TType extends ChartType> {
   };
 }
 
-export const SubTitle: Plugin;
-export const Title: Plugin;
+export declare const SubTitle: Plugin;
+export declare const Title: Plugin;
 
 export interface TitleOptions {
   /**
@@ -2535,7 +2533,7 @@ export interface Tooltip extends Plugin {
   readonly positioners: TooltipPositionerMap;
 }
 
-export const Tooltip: Tooltip;
+export declare const Tooltip: Tooltip;
 
 export interface TooltipCallbacks<
   TType extends ChartType,
@@ -3135,7 +3133,7 @@ export type CategoryScaleOptions = Omit<CartesianScaleOptions, 'min' | 'max'> &
 };
 
 export type CategoryScale<O extends CategoryScaleOptions = CategoryScaleOptions> = Scale<O>
-export const CategoryScale: ChartComponent & {
+export declare const CategoryScale: ChartComponent & {
   prototype: CategoryScale;
   new <O extends CategoryScaleOptions = CategoryScaleOptions>(cfg: AnyObject): CategoryScale<O>;
 };
@@ -3184,7 +3182,7 @@ export type LinearScaleOptions = CartesianScaleOptions & {
 };
 
 export type LinearScale<O extends LinearScaleOptions = LinearScaleOptions> = Scale<O>
-export const LinearScale: ChartComponent & {
+export declare const LinearScale: ChartComponent & {
   prototype: LinearScale;
   new <O extends LinearScaleOptions = LinearScaleOptions>(cfg: AnyObject): LinearScale<O>;
 };
@@ -3208,7 +3206,7 @@ export type LogarithmicScaleOptions = CartesianScaleOptions & {
 };
 
 export type LogarithmicScale<O extends LogarithmicScaleOptions = LogarithmicScaleOptions> = Scale<O>
-export const LogarithmicScale: ChartComponent & {
+export declare const LogarithmicScale: ChartComponent & {
   prototype: LogarithmicScale;
   new <O extends LogarithmicScaleOptions = LogarithmicScaleOptions>(cfg: AnyObject): LogarithmicScale<O>;
 };
@@ -3304,13 +3302,13 @@ export interface TimeScale<O extends TimeScaleOptions = TimeScaleOptions> extend
   normalize(values: number[]): number[];
 }
 
-export const TimeScale: ChartComponent & {
+export declare const TimeScale: ChartComponent & {
   prototype: TimeScale;
   new <O extends TimeScaleOptions = TimeScaleOptions>(cfg: AnyObject): TimeScale<O>;
 };
 
 export type TimeSeriesScale<O extends TimeScaleOptions = TimeScaleOptions> = TimeScale<O>
-export const TimeSeriesScale: ChartComponent & {
+export declare const TimeSeriesScale: ChartComponent & {
   prototype: TimeSeriesScale;
   new <O extends TimeScaleOptions = TimeScaleOptions>(cfg: AnyObject): TimeSeriesScale<O>;
 };
@@ -3466,7 +3464,7 @@ export interface RadialLinearScale<O extends RadialLinearScaleOptions = RadialLi
   getPointLabelPosition(index: number): ChartArea;
   getBasePosition(index: number): { x: number; y: number; angle: number };
 }
-export const RadialLinearScale: ChartComponent & {
+export declare const RadialLinearScale: ChartComponent & {
   prototype: RadialLinearScale;
   new <O extends RadialLinearScaleOptions = RadialLinearScaleOptions>(cfg: AnyObject): RadialLinearScale<O>;
 };
index 6e38e68eac6be8ce2ef10c3aa8efa87463427cfd..c998bf603df9a0fb8b9b2f043751ee9ec91de5cd 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '..';
+import { Chart } from '../../src/types';
 
 const chart = new Chart('id', {
   type: 'bar',
index 584a33636f14ded2c3af72e28182df5e072dc5bc..9d17efcb0f0adc90c455202e919ec004d59275d2 100644 (file)
@@ -10,9 +10,9 @@ let fd;
 try {
   const fn = path.resolve(__dirname, 'autogen_helpers.ts');
   fd = fs.openSync(fn, 'w+');
-  fs.writeSync(fd, 'import * as helpers from \'../helpers\';\n\n');
+  fs.writeSync(fd, 'import * as helpers from \'../../src/helpers/types\';\n\n');
 
-  fs.writeSync(fd, 'const testKeys = [];\n');
+  fs.writeSync(fd, 'const testKeys: unknown[] = [];\n');
   for (const key of Object.keys(helpers)) {
     if (key[0] !== '_' && typeof helpers[key] === 'function') {
       fs.writeSync(fd, `testKeys.push(helpers.${key});\n`);
index 32831901e2c6534a1932aa1b29a84fc3d6e005c1..16ec835266a3c7b2a242ed3f187886bfcb8e3047 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '..';
+import { Chart } from '../../src/types';
 
 const chart = new Chart('chart', {
   type: 'bar',
index 5924dd5f95620e3d277dec1ee34df30597735171..aa1ba5110070d27e7960452ab1c2a884dfe12539 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart, ChartOptions } from '../..';
+import { Chart, ChartOptions } from '../../../src/types';
 
 const chart = new Chart('test', {
   type: 'bubble',
index 76eb6eb6fb15b93de85e88359db179661bcb888b..ccd8f337a35a2aabd36784ba53eda6e66e1cf656 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart, ChartMeta, Element } from '../..';
+import { Chart, ChartMeta, Element } from '../../../src/types';
 
 const chart = new Chart('id', {
   type: 'doughnut',
index cf2d06943869ef647d47924e3ac1c5ca37c17885..a238b269083ed1c9e79649f629f8424102ec5a0c 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart, ChartMeta, Element } from '../..';
+import { Chart, ChartMeta, Element } from '../../../src/types';
 
 const chart = new Chart('id', {
   type: 'doughnut',
index e72d309c2aa08acff1493662a98427e5026be85a..9f39caf6fe2486ba5bdc5ab2cbf64cf7a3461fe8 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../..';
+import { Chart } from '../../../src/types';
 
 const chart = new Chart('id', {
   type: 'doughnut',
index 7a726da37ce3fe4d3966d7b40296c262959508c9..0562250bb26d6a9290879fc0e1600d92921bd047 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../..';
+import { Chart } from '../../../src/types';
 
 const chart = new Chart('id', {
   type: 'line',
index 5d07063a951fc8c22eaaa6055f22baa73bd693fb..6478cdaa9c4f3de5b8a81c05c195ca1a52a40b92 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../..';
+import { Chart } from '../../../src/types';
 
 const chart = new Chart('id', {
   type: 'line',
index 0025641bde4138bc7ab96c9f97bc28029a1e148b..da6c8bcb714581ac0caf28b77259b5cb5f03d358 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../..';
+import { Chart } from '../../../src/types';
 
 const chart = new Chart('id', {
   type: 'line',
index daf2b7be74a472205dddd9dd764642186f67273e..b5dce9d8308126caf0e1db319afb74d81889469d 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../..';
+import { Chart } from '../../../src/types';
 
 const chart = new Chart('id', {
   type: 'line',
index 7ef753619766a2f5ef37ad7e7645066e2b2ec32e..d55924f3e3c5ee7e7bda0bedbdc383e744892b30 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart, ChartOptions } from '../..';
+import { Chart, ChartOptions } from '../../../src/types';
 
 const chart = new Chart('test', {
   type: 'radar',
index 0e6a2d87f7926dbcc4e1a5a755de8f3dca6705f6..7c1ca05b30841bdcf8bbab1dd28027acacf464eb 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '..';
+import { Chart } from '../../src/types';
 
 const chart = new Chart('chart', {
   type: 'bar',
index bb86a0aaec317802efd86ce97f7c5e8214498c9a..3ee85f2abf0c1a521e2428888952e14b4628ad20 100644 (file)
@@ -1,4 +1,4 @@
-import { ChartDataset } from '..';
+import { ChartDataset } from '../../src/types';
 
 const dataset: ChartDataset = {
   data: [10, null, 20],
diff --git a/types/tests/date_adapter.ts b/types/tests/date_adapter.ts
new file mode 100644 (file)
index 0000000..a6e2844
--- /dev/null
@@ -0,0 +1,14 @@
+import { _adapters } from '../../src/types';
+
+_adapters._date.override<{myOption: boolean}>({
+  init() {
+    const booleanOption: boolean = this.options.myOption;
+
+    // @ts-expect-error Options is readonly.
+    this.options = {};
+  },
+  // @ts-expect-error Should return string.
+  format(timestamp) {
+    const numberArg: number = timestamp;
+  }
+});
index c4c591000ee6c24e50ce962931c3384ee3e213af..096eafab5068d17e5c3afbd6e86d1d8a349ba4db 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '..';
+import { Chart } from '../../src/types';
 
 Chart.defaults.scales.time.time.minUnit = 'day';
 
index 791684c64b1e946326ecd6123df50aed6fa0fee2..3792fc37e5911a4b903ece286b018ee705f87a40 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../..';
+import { Chart } from '../../../src/types';
 
 const chart = new Chart('id', {
   type: 'line',
index b0a89c5b08d28b47faaed80e266a4c06a9c7941c..f03b27b5cd11a625f62e70d2dae30d3680ed97ce 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../..';
+import { Chart } from '../../../src/types';
 
 Chart.register({
   id: 'my-plugin',
index 0b6a10dcc139355a7d2347fae87fef592c82c5f2..e78c41745e856b7bbbf50df116f3187afb9f3eec 100644 (file)
@@ -1,5 +1,5 @@
 import { AnyObject } from '../../basic';
-import { CartesianScaleOptions, Chart, Scale } from '../..';
+import { CartesianScaleOptions, Chart, Scale } from '../../../src/types';
 
 export type TestScaleOptions = CartesianScaleOptions & {
   testOption?: boolean
index 3450bbfe0ec86cac4110dbde6b56ab2981542f6b..46de29b6c4d3ef9b717ef4485fcde2b2c901cc44 100644 (file)
@@ -1,6 +1,6 @@
 import {
   Chart, ChartData, ChartConfiguration, Element
-} from '..';
+} from '../../src/types';
 
 const data: ChartData<'line'> = { datasets: [] };
 const chartItem = 'item';
index 544ed4f3ea8cb7f91777bd6364569f074f163365..25007207fb27ca1ec66f62d022e558c74219fef3 100644 (file)
@@ -1,4 +1,4 @@
-import { LayoutPosition } from '../..';
+import { LayoutPosition } from '../../../src/types';
 
 const left: LayoutPosition = 'left';
 const right: LayoutPosition = 'right';
index 2ec8b895cfec552a9ab0daf6d35d07354d27087d..231a83b79d77e7e5818396fd56fae8a6951ecd2f 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '..';
+import { Chart } from '../../src/types';
 
 const chart = new Chart('test', {
   type: 'bar',
index 1e184e561eeaa9ad4691846f1722148d985d7f9c..28701cbbbbd9472dca42fb27b82bbf5b7013b01e 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '..';
+import { Chart } from '../../src/types';
 
 Chart.overrides.bar.scales.x.type = 'time';
 
index 54b207a4bebd344fac5a35db5a607558368f6388..6123ce9c017a1625c1064a47f0ed69085e67c1db 100644 (file)
@@ -1,4 +1,4 @@
-import { ParsedDataType } from '..';
+import { ParsedDataType } from '../../src/types';
 
 interface test {
   pie: ParsedDataType<'pie'>,
index 9ca1edea64f1fc02faa2c20539547a7a13278cb8..cc2896b688ceea1bd6d609d15875d30c12e20845 100644 (file)
@@ -1,4 +1,4 @@
-import { defaults } from '../..';
+import { defaults } from '../../../src/types';
 
 // https://github.com/chartjs/Chart.js/issues/8711
 const original = defaults.plugins.legend.labels.generateLabels;
index a6659bac7c6edd2c8bf86d6a0699bb35a71c738f..2ca4afbed838ff626e1a3e159ea3c1cfd53450cf 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart, DecimationAlgorithm } from '../../..';
+import { Chart, DecimationAlgorithm } from '../../../../src/types';
 
 const chart = new Chart('id', {
   type: 'bubble',
index 3768ddedae895a6f7f74dcc1d8607f47e1a26234..e43a94fe1918c65f93929ee3484d96af4c10e466 100644 (file)
@@ -1,4 +1,4 @@
-import { ChartDataset } from '../../..';
+import { ChartDataset } from '../../../../src/types';
 
 const dataset: ChartDataset = {
   data: [],
index 56b37f29571371cb33aa4b238ab29bd4c4d04dd6..6f32fe20be02cd7fd15ccc9f7c01dd4b98e939c4 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../../..';
+import { Chart } from '../../../../src/types';
 
 const chart = new Chart('id', {
   type: 'line',
index 343828d8dd53fafe65a7a2c385beb0211969fa5f..aae63fcb7a65cb31c9686deceabfa9be0b04b0d1 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../../..';
+import { Chart } from '../../../../src/types';
 
 const chart = new Chart('id', {
   type: 'line',
index d7fb45959b623d9546d72957a2bf8ce22cde63ca..52c58bea0e1b9d29e328ddfb365e6292d5f0ad22 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../../..';
+import { Chart } from '../../../../src/types';
 
 const chart = new Chart('id', {
   type: 'bar',
index d1488b681cf2a2ddb783016c4fb5c63516437a80..3817b0261e93cb6fd91338048530541d44f40b8f 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../../..';
+import { Chart } from '../../../../src/types';
 
 Chart.overrides.bubble.plugins.tooltip.callbacks.label = (item) => {
   const { x, y, _custom: r } = item.parsed;
index 36c54d7e0f6167b8428288e0b3d6ee9dcd47630d..bc90008f6cbe11d3de69e15ea9e7b66b12b12b6b 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../../..';
+import { Chart } from '../../../../src/types';
 
 const chart = new Chart('id', {
   type: 'bar',
index 49979d7a808b60e792890f79b06ea716d594b4e9..ddc5f5e24dc66d7d11f1b621a0fb23fcde6fed3c 100644 (file)
@@ -24,7 +24,7 @@ import {
   Title,
   SubTitle,
   Tooltip
-} from '..';
+} from '../../src/types';
 
 Chart.register(
   ArcElement,
index c097601a9fd9600e0d71b11d0fc55b817e58a077..fa8c806a771e0a1a2ec85c77326ee400c1f44d91 100644 (file)
@@ -1,4 +1,4 @@
-import { ChartOptions } from '../..';
+import { ChartOptions } from '../../../src/types';
 
 const chartOptions: ChartOptions<'line'> = {
   scales: {
index a521f015036e2bf8d490de09559234bd75a9a259..65debaffa5227b97dd0426178f60808ef6a3da69 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart, ScaleOptions } from '../..';
+import { Chart, ScaleOptions } from '../../../src/types';
 
 const chart = new Chart('test', {
   type: 'bar',
index 9c1c38bf45cafbac11bb39f4d76858ee4071dd81..377c3e268a963506f46e05e91e353a2c18ada59d 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '../..';
+import { Chart } from '../../../src/types';
 
 const chart = new Chart('id', {
   type: 'line',
index bf9cec805264bf972d38d2da583181e140b01d38..248441cdaa42514612e80bce7bed8a8bb62150f1 100644 (file)
@@ -1,4 +1,4 @@
-import { ChartType, Scriptable, ScriptableContext } from '..';
+import { ChartType, Scriptable, ScriptableContext } from '../../src/types';
 
 interface test {
   pie?: Scriptable<number, ScriptableContext<'pie'>>,
index 3e2115f655fe8089a7e92facee1f76aea7b8ce21..59fe94af9302564c0f9edd4bcfedbb37085f8814 100644 (file)
@@ -1,4 +1,4 @@
-import { ChartConfiguration } from '..';
+import { ChartConfiguration } from '../../src/types';
 
 const getConfig = (): ChartConfiguration<'bar'> => {
   return {
index ea3951d2ead0f88ff214d0a1d3012a0bd8e87122..5e8823a7e87747650e31202587e968caa889543b 100644 (file)
@@ -1,4 +1,4 @@
-import { Chart } from '..';
+import { Chart } from '../../src/types';
 
 const chart = new Chart('id', {
   type: 'scatter',
index a8494a0a8ae37e2eb22a03e96515a7e337099d45..62d8a4c56684026bd6f882464822512f17615a95 100644 (file)
@@ -1,13 +1,10 @@
 {
+  "extends": "../../tsconfig.json",
   "compilerOptions": {
-    "target": "ES6",
-    "moduleResolution": "Node",
-    "alwaysStrict": true,
-    "strict": true,
     "noEmit": true
   },
   "include": [
-    "./**/*.ts",
-    "../index.d.ts"
+    "../",
+    "../../src/"
   ]
 }
index 8313d9fae9b50130289d19fc688cca5075c66728..a8533f22da8ea99a02e93e5d5f78a1d165300ec1 100644 (file)
@@ -18,4 +18,3 @@ export type DistributiveArray<T> = [T] extends [unknown] ? Array<T> : never
 
 // https://stackoverflow.com/a/50375286
 export type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
-