From 1eac02334afba3957000f9daa0a13aad5980f6cf Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 27 Mar 2017 11:42:48 -0700 Subject: [PATCH 1/3] Move web-animations-js inside types folder --- {web-animations-js => types/web-animations-js}/tsconfig.json | 0 .../web-animations-js}/web-animations-js-tests.ts | 0 .../web-animations-js}/web-animations-js.d.ts | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename {web-animations-js => types/web-animations-js}/tsconfig.json (100%) rename {web-animations-js => types/web-animations-js}/web-animations-js-tests.ts (100%) rename {web-animations-js => types/web-animations-js}/web-animations-js.d.ts (100%) diff --git a/web-animations-js/tsconfig.json b/types/web-animations-js/tsconfig.json similarity index 100% rename from web-animations-js/tsconfig.json rename to types/web-animations-js/tsconfig.json diff --git a/web-animations-js/web-animations-js-tests.ts b/types/web-animations-js/web-animations-js-tests.ts similarity index 100% rename from web-animations-js/web-animations-js-tests.ts rename to types/web-animations-js/web-animations-js-tests.ts diff --git a/web-animations-js/web-animations-js.d.ts b/types/web-animations-js/web-animations-js.d.ts similarity index 100% rename from web-animations-js/web-animations-js.d.ts rename to types/web-animations-js/web-animations-js.d.ts From 2808017b657b7e06e1f5f19a0b1536229e46b1c6 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 27 Mar 2017 12:56:53 -0700 Subject: [PATCH 2/3] Make web-animations-js strictNullChecks safe --- types/web-animations-js/tsconfig.json | 4 +- .../web-animations-js-tests.ts | 49 ++++++++++--------- .../web-animations-js/web-animations-js.d.ts | 4 +- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/types/web-animations-js/tsconfig.json b/types/web-animations-js/tsconfig.json index dbf76f478e..74f7691f83 100644 --- a/types/web-animations-js/tsconfig.json +++ b/types/web-animations-js/tsconfig.json @@ -8,7 +8,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -21,4 +21,4 @@ "web-animations-js.d.ts", "web-animations-js-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/web-animations-js/web-animations-js-tests.ts b/types/web-animations-js/web-animations-js-tests.ts index 3072c936a0..ece6c3cc01 100644 --- a/types/web-animations-js/web-animations-js-tests.ts +++ b/types/web-animations-js/web-animations-js-tests.ts @@ -46,7 +46,9 @@ function test_AnimationsApiNext() { effectNode.style.left = bounds.left + bounds.width / 2 + 'px'; effectNode.style.top = bounds.top + bounds.height / 2 + 'px'; const header = document.querySelector('header'); - header.appendChild(effectNode); + if (header) { + header.appendChild(effectNode); + } const newColor = 'hsl(' + Math.round(Math.random() * 255) + ', 46%, 42%)'; effectNode.style.background = newColor; const scaleSteps = [{ transform: 'scale(0)' }, { transform: 'scale(1)' }]; @@ -63,31 +65,32 @@ function test_AnimationsApiNext() { // http://codepen.io/rachelnabors/pen/eJyWzm/?editors=0010 function test_whiteRabbit() { var whiteRabbit = document.getElementById("rabbit"); + if (whiteRabbit) { + var rabbitDownKeyframes = new KeyframeEffect( + whiteRabbit, + [ + { transform: 'translateY(0%)' }, + { transform: 'translateY(100%)' } + ], + { duration: 3000, fill: 'forwards' } + ); + var rabbitDownAnimation = new Animation(rabbitDownKeyframes, document.timeline); + // On tap or click, + whiteRabbit.addEventListener("mousedown", downHeGoes, false); + whiteRabbit.addEventListener("touchstart", downHeGoes, false); - var rabbitDownKeyframes = new KeyframeEffect( - whiteRabbit, - [ - { transform: 'translateY(0%)' }, - { transform: 'translateY(100%)' } - ], - { duration: 3000, fill: 'forwards' } - ); + // Trigger a single-fire animation + function downHeGoes(event: Event) { - var rabbitDownAnimation = new Animation(rabbitDownKeyframes, document.timeline); + // Remove those event listeners + whiteRabbit!.removeEventListener("mousedown", downHeGoes, false); + whiteRabbit!.removeEventListener("touchstart", downHeGoes, false); - // On tap or click, - whiteRabbit.addEventListener("mousedown", downHeGoes, false); - whiteRabbit.addEventListener("touchstart", downHeGoes, false); - - // Trigger a single-fire animation - function downHeGoes(event: Event) { - - // Remove those event listeners - whiteRabbit.removeEventListener("mousedown", downHeGoes, false); - whiteRabbit.removeEventListener("touchstart", downHeGoes, false); - - // Play rabbit animation - rabbitDownAnimation.play(); + // Play rabbit animation + rabbitDownAnimation.play(); + } } + + } diff --git a/types/web-animations-js/web-animations-js.d.ts b/types/web-animations-js/web-animations-js.d.ts index a151ef73b3..ddc972ba0e 100644 --- a/types/web-animations-js/web-animations-js.d.ts +++ b/types/web-animations-js/web-animations-js.d.ts @@ -24,7 +24,7 @@ declare class AnimationPlaybackEvent { interface AnimationKeyFrame { easing?: string; offset?: number; - [key: string]: string | string[] | number | number[]; + [key: string]: string | string[] | number | number[] | undefined; } interface AnimationTimeline { @@ -89,4 +89,4 @@ interface Element { } interface Document { timeline: AnimationTimeline; -} \ No newline at end of file +} From 9c038752779a60df242c6f3f761deb4eda94214d Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 27 Mar 2017 13:32:20 -0700 Subject: [PATCH 3/3] Move to index.d.ts and fix other lints Also turn on linting. --- types/web-animations-js/{web-animations-js.d.ts => index.d.ts} | 2 +- types/web-animations-js/tsconfig.json | 2 +- types/web-animations-js/tslint.json | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) rename types/web-animations-js/{web-animations-js.d.ts => index.d.ts} (98%) create mode 100644 types/web-animations-js/tslint.json diff --git a/types/web-animations-js/web-animations-js.d.ts b/types/web-animations-js/index.d.ts similarity index 98% rename from types/web-animations-js/web-animations-js.d.ts rename to types/web-animations-js/index.d.ts index ddc972ba0e..24c6282eab 100644 --- a/types/web-animations-js/web-animations-js.d.ts +++ b/types/web-animations-js/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for web-animations-js v2.2.2 +// Type definitions for web-animations-js 2.2 // Project: https://github.com/web-animations/web-animations-js // Definitions by: Kristian Moerch // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/web-animations-js/tsconfig.json b/types/web-animations-js/tsconfig.json index 74f7691f83..6f7d4d67cb 100644 --- a/types/web-animations-js/tsconfig.json +++ b/types/web-animations-js/tsconfig.json @@ -18,7 +18,7 @@ "forceConsistentCasingInFileNames": true }, "files": [ - "web-animations-js.d.ts", + "index.d.ts", "web-animations-js-tests.ts" ] } diff --git a/types/web-animations-js/tslint.json b/types/web-animations-js/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/types/web-animations-js/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" }