Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: TypeScript types #7668

Merged
merged 35 commits into from
Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
784b9f9
start with helper types
sgratzl Jul 21, 2020
3d538a3
first version of types
sgratzl Jul 21, 2020
f621107
restructure types
sgratzl Jul 22, 2020
7282d21
plugin options
sgratzl Jul 22, 2020
df0c110
update elements
sgratzl Jul 22, 2020
7ee7b08
fix typo
sgratzl Jul 23, 2020
07f8af2
start with controller options
sgratzl Jul 23, 2020
23d3fb1
add more options
sgratzl Jul 23, 2020
4871d59
integrate feedback
sgratzl Jul 23, 2020
9656c9f
more controller options
sgratzl Jul 23, 2020
890cc65
scale options
sgratzl Jul 23, 2020
0905663
unify style
sgratzl Jul 23, 2020
d056495
run formatter
sgratzl Jul 23, 2020
e770532
small fix
sgratzl Jul 23, 2020
3e11285
add unbundled types
sgratzl Jul 24, 2020
d2d69f1
avoid chart in helpers
sgratzl Jul 24, 2020
08de23d
small refctorings
sgratzl Jul 25, 2020
6c52a85
first working version
sgratzl Jul 25, 2020
e37b993
format types
sgratzl Jul 25, 2020
e4dd7b4
revert dependencies
sgratzl Jul 25, 2020
40b73c3
small tunings
sgratzl Jul 25, 2020
3ae5e6b
integrate initial feedback
sgratzl Jul 25, 2020
a1b6ae4
integrate feedback
sgratzl Jul 26, 2020
1b16f78
integrate feedback
sgratzl Jul 27, 2020
bcea5cc
small comment improvements
sgratzl Jul 27, 2020
e031d3e
docu: small text style improvements
sgratzl Jul 27, 2020
cc809f2
bundle typings using rollup-dts-plugin
sgratzl Jul 27, 2020
9dea376
update dist files for types
sgratzl Jul 27, 2020
62f7f02
add color and font to base options
sgratzl Jul 27, 2020
63112db
add legend and title plugin chart options
sgratzl Jul 27, 2020
92a4a12
fix element constructors
sgratzl Jul 28, 2020
1716c98
add active update mode
sgratzl Jul 28, 2020
3fdc0e3
integrate feedback
sgratzl Jul 28, 2020
46d3d5d
better scale types
sgratzl Jul 28, 2020
1679264
helper for extracting dataset
sgratzl Jul 28, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 44 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"unpkg": "dist/chart.min.js",
"main": "dist/chart.js",
"module": "dist/chart.esm.js",
"types": "dist/chart.esm.d.ts",
"keywords": [
"canvas",
"charts",
Expand All @@ -25,7 +26,9 @@
},
"files": [
"dist/*.js",
"helpers/**/*.js"
"dist/*.d.ts",
"helpers/**/*.js",
"helpers/**/*.d.ts"
],
"scripts": {
"autobuild": "rollup -c -w",
Expand Down Expand Up @@ -75,6 +78,7 @@
"rollup": "^2.15.0",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-cleanup": "^3.1.1",
"rollup-plugin-dts": "^1.4.9",
"rollup-plugin-terser": "^6.1.0",
"rollup-plugin-web-worker-loader": "^1.3.0",
"typedoc": "^0.17.7",
Expand Down
21 changes: 21 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

const babel = require('rollup-plugin-babel');
const cleanup = require('rollup-plugin-cleanup');
const dts = require('rollup-plugin-dts').default;
const glob = require('glob');
const inject = require('@rollup/plugin-inject');
const json = require('@rollup/plugin-json');
Expand All @@ -14,10 +15,14 @@ const input = 'src/index.js';
const inputESM = {
'dist/chart.esm': 'src/index.esm.js',
};
const inputESMTypings = {};
glob('src/helpers/helpers.*.js', (_er, files) => {
files.forEach(file => {
inputESM[file.replace(/src\/|helpers\.|\.js/g, '')] = file;
});
Object.keys(inputESM).forEach((key) => {
inputESMTypings[key.replace('src', 'types')] = inputESM[key].replace('src', 'types').replace(/\.js$/, '.d.ts');
});
});

const banner = `/*!
Expand Down Expand Up @@ -94,5 +99,21 @@ module.exports = [
format: 'esm',
indent: false,
},
},
// ES6 Typings builds
// dist/chart.esm.d.ts
// helpers/*.d.ts
{
input: inputESMTypings,
plugins: [
dts()
],
output: {
dir: './',
chunkFileNames: 'helpers/chunks/[name].ts',
banner,
format: 'esm',
indent: false,
},
}
];
25 changes: 25 additions & 0 deletions test/types/simple.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {Chart, IBarControllerConfiguration} from '../..';

const bar = new Chart(document.createElement('canvas'), {
type: 'bar',
data: {
labels: ['A', 'B'],
datasets: [
{
data: [1,2],
}
]
}
});

const barTyped = new Chart<number, string, IBarControllerConfiguration<number, string>>(document.createElement('canvas'), {
type: 'bar',
data: {
labels: ['A', 'B'],
datasets: [
{
data: [1,2],
}
]
}
});
Loading