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

Fix animation types, add test #8476

Merged
merged 1 commit into from
Feb 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"lint-js": "eslint samples/**/*.html samples/**/*.js src/**/*.js test/**/*.js",
"lint-md": "markdownlint-cli2 \"**/*.md\" \"#**/node_modules\"",
"lint-tsc": "tsc",
"lint-types": "eslint types/**/*.d.ts",
"lint-types": "eslint types/**/*.d.ts && tsc -p types/tests/",
"lint": "concurrently \"npm:lint-*\"",
"test": "npm run lint && cross-env NODE_ENV=test karma start --auto-watch --single-run --coverage --grep",
"typedoc": "npx typedoc"
Expand Down
6 changes: 3 additions & 3 deletions types/index.esm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,7 @@ export type AnimationSpec = {
}

export type AnimationsSpec = {
[name: string]: AnimationSpec & {
[name: string]: false | AnimationSpec & {
properties: string[];

/**
Expand All @@ -1507,7 +1507,7 @@ export type AnimationsSpec = {
*
*/
to: Scriptable<Color | number | boolean, ScriptableContext>;
} | false
}
}

export type TransitionSpec = {
Expand All @@ -1520,7 +1520,7 @@ export type TransitionsSpec = {
}

export type AnimationOptions = {
animation: AnimationSpec & {
animation: false | AnimationSpec & {
/**
* Callback called on each step of an animation.
*/
Expand Down
42 changes: 42 additions & 0 deletions types/tests/animation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Chart } from '../index.esm';

const chart = new Chart('id', {
type: 'bar',
data: {
labels: [],
datasets: [{
data: []
}]
},
options: {
animation: false,
animations: {
colors: false,
numbers: {
properties: ['a', 'b'],
type: 'number',
from: 0,
to: 10,
delay: (ctx) => ctx.dataIndex * 100,
duration: (ctx) => ctx.datasetIndex * 1000,
loop: true,
easing: 'linear'
}
},
transitions: {
show: {
animation: {
duration: 10
},
animations: {
numbers: false
}
},
custom: {
animation: {
duration: 10
}
}
}
},
});
12 changes: 12 additions & 0 deletions types/tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "ES6",
"moduleResolution": "Node",
"alwaysStrict": true,
"noEmit": true
},
"include": [
"*.ts",
"../index.esm.d.ts"
]
}