Skip to content

Commit 2031cdf

Browse files
authored
Preparing the project for TypeScript (#10595)
* Add Typescript to the build * Converts the `helpers.core` to Typescript as an example * Converts the `core.element` to Typescript
1 parent 75793eb commit 2031cdf

File tree

78 files changed

+1262
-692
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1262
-692
lines changed

.eslintrc.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,24 @@ rules:
3636
es/no-regexp-s-flag: "error"
3737
es/no-regexp-unicode-property-escapes: "error"
3838
es/no-dynamic-import: "off"
39+
40+
overrides:
41+
- files: ['**/*.ts']
42+
parser: '@typescript-eslint/parser'
43+
plugins:
44+
- '@typescript-eslint'
45+
extends:
46+
- chartjs
47+
- plugin:@typescript-eslint/recommended
48+
49+
rules:
50+
# Replace stock eslint rules with typescript-eslint equivalents for proper
51+
# TypeScript support.
52+
indent: "off"
53+
"@typescript-eslint/indent": ["error", 2]
54+
no-use-before-define: "off"
55+
'@typescript-eslint/no-use-before-define': "error"
56+
no-shadow: "off"
57+
'@typescript-eslint/no-shadow': "error"
58+
space-before-function-paren: "off"
59+
'@typescript-eslint/space-before-function-paren': [2, never]

.size-limit.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function modifyWebpackConfig(config) {
77
module.exports = [
88
{
99
path: 'dist/chart.js',
10-
limit: '75 KB',
10+
limit: '77 KB',
1111
webpack: false,
1212
running: false
1313
},

auto/auto.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Chart} from '../types';
1+
import {Chart} from '../dist/types';
22

3-
export * from '../types';
3+
export * from '../dist/types';
44
export default Chart;

docs/developers/charts.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ When adding a new chart type, `ChartTypeRegistry` must contains the declarations
130130

131131
For example, to provide typings for a new chart type that extends from a bubble chart, you would add a `.d.ts` containing:
132132

133-
```ts
134-
import { ChartTypeRegistry } from 'chart.js'
133+
```typescript
134+
import { ChartTypeRegistry } from 'chart.js';
135135

136136
declare module 'chart.js' {
137137
interface ChartTypeRegistry {

helpers/helpers.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from '../types/helpers';
1+
export * from '../dist/helpers/types';

karma.conf.cjs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ module.exports = async function(karma) {
2727
}
2828

2929
if (args.coverage) {
30-
build.plugins = [
31-
json(),
32-
resolve(),
30+
build.plugins.push(
3331
istanbul({exclude: ['node_modules/**/*.js', 'package.json']})
34-
];
32+
);
3533
}
3634

3735
karma.set({
@@ -92,14 +90,14 @@ module.exports = async function(karma) {
9290
'node_modules/moment-timezone/builds/moment-timezone-with-data.min.js',
9391
{pattern: 'test/index.js', watched: false},
9492
{pattern: 'test/BasicChartWebWorker.js', included: false},
95-
{pattern: 'src/index.umd.js', watched: false},
93+
{pattern: 'src/index.umd.ts', watched: false},
9694
'node_modules/chartjs-adapter-moment/dist/chartjs-adapter-moment.js',
9795
{pattern: specPattern}
9896
],
9997

10098
preprocessors: {
10199
'test/index.js': ['rollup'],
102-
'src/index.umd.js': ['sources']
100+
'src/index.umd.ts': ['sources']
103101
},
104102

105103
rollupPreprocessor: {

0 commit comments

Comments
 (0)