From 5784f119bebed54d254372de5d218c2b6177ffb1 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Tue, 24 Jul 2018 09:17:19 -0700 Subject: [PATCH 1/8] Update type definitions State is optional on keyframes when you have a default animation; delay was missing on SpringProps --- index.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 81f24f47f3..97c24af1a2 100644 --- a/index.d.ts +++ b/index.d.ts @@ -85,6 +85,10 @@ interface SpringProps { * @default undefined */ inject?: any + /** + * Animation start delay, optional + */ + delay?: number } export const config: { @@ -227,7 +231,7 @@ export class ParallaxLayer< > extends PureComponent> {} interface KeyframesProps { - state: string + state?: string } export class Keyframes extends Component< From 793080017e1c5408f98f198a16c3551075b6c2ad Mon Sep 17 00:00:00 2001 From: Benjamin Date: Tue, 24 Jul 2018 11:06:09 -0700 Subject: [PATCH 2/8] Support extra props Make it so that other props can be added to current primitives, to support prop forwarding. Also automatically support prop forwarding from Keyframes to inbuilt primitives --- index.d.ts | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/index.d.ts b/index.d.ts index 97c24af1a2..8ef18cde05 100644 --- a/index.d.ts +++ b/index.d.ts @@ -105,7 +105,7 @@ export const config: { } export class Spring extends PureComponent< - SpringProps + SpringProps & S > {} export function interpolate( @@ -117,10 +117,10 @@ export const animated: { [Tag in keyof JSX.IntrinsicElements]: ComponentClass< JSX.IntrinsicElements[Tag] > -} +}; -type TransitionKeyProps = string | number -type TransitionItemProps = string | number | object +type TransitionKeyProps = string | number; +type TransitionItemProps = string | number | object; interface TransitionProps { /** @@ -174,7 +174,7 @@ interface TransitionProps { export class Transition< S extends object, DS extends object -> extends PureComponent> {} +> extends PureComponent & S> {} type TrailKeyProps = string | number type TrailKeyItemProps = string | number | object @@ -199,7 +199,7 @@ interface TrailProps { } export class Trail extends PureComponent< - TrailProps + TrailProps & S > {} interface ParallaxProps { @@ -215,7 +215,7 @@ interface ParallaxProps { export class Parallax< S extends object, DS extends object -> extends PureComponent> {} +> extends PureComponent & S> {} interface ParallaxLayerProps { factor?: number @@ -228,25 +228,25 @@ interface ParallaxLayerProps { export class ParallaxLayer< S extends object, DS extends object -> extends PureComponent> {} +> extends PureComponent & S> {} interface KeyframesProps { - state?: string + state: string } -export class Keyframes extends Component< - KeyframesProps +export class Keyframes extends PureComponent< + KeyframesProps & S > { static create( primitive: ComponentType ): (states: object) => (props: object) => Keyframes static Spring( states: object - ): (props: object) => Keyframes + ): (props: object) => Keyframes | Spring static Trail( states: object - ): (props: object) => Keyframes + ): (props: object) => Keyframes | Trail static Transition( states: object - ): (props: object) => Keyframes + ): (props: object) => Keyframes | Transition } From e3b4c95ca8d70993d0679c64e840934d30f3470b Mon Sep 17 00:00:00 2001 From: Benjamin Date: Tue, 24 Jul 2018 11:06:29 -0700 Subject: [PATCH 3/8] Make state optional again --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 8ef18cde05..547ef53db2 100644 --- a/index.d.ts +++ b/index.d.ts @@ -231,7 +231,7 @@ export class ParallaxLayer< > extends PureComponent & S> {} interface KeyframesProps { - state: string + state?: string } export class Keyframes extends PureComponent< From 2911f3b6d32f0a5911c2523ee774a8154206a360 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Tue, 24 Jul 2018 11:09:20 -0700 Subject: [PATCH 4/8] Remove combing Keyframe with primitive types Nevermind this doesn't do what I thought it would do --- index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 547ef53db2..f91ef7f285 100644 --- a/index.d.ts +++ b/index.d.ts @@ -242,11 +242,11 @@ export class Keyframes extends PureComponen ): (states: object) => (props: object) => Keyframes static Spring( states: object - ): (props: object) => Keyframes | Spring + ): (props: object) => Keyframes static Trail( states: object - ): (props: object) => Keyframes | Trail + ): (props: object) => Keyframes static Transition( states: object - ): (props: object) => Keyframes | Transition + ): (props: object) => Keyframes } From 89a420c0f599d290200e939766b134e7fd344faa Mon Sep 17 00:00:00 2001 From: Benjamin Date: Tue, 24 Jul 2018 11:29:47 -0700 Subject: [PATCH 5/8] Bringing back folding primitive types into keyframes Typescript is both beautiful and terrible at the same time --- index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index f91ef7f285..981e8119c4 100644 --- a/index.d.ts +++ b/index.d.ts @@ -242,11 +242,11 @@ export class Keyframes extends PureComponen ): (states: object) => (props: object) => Keyframes static Spring( states: object - ): (props: object) => Keyframes + ): (props: object) => Keyframes, Exclude, {to:DS}>>, DS> static Trail( states: object - ): (props: object) => Keyframes + ): (props: object) => Keyframes, DS> static Transition( states: object - ): (props: object) => Keyframes + ): (props: object) => Keyframes, DS> } From 8bef437a12933ae743d67163abf8391df1a891c4 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Tue, 24 Jul 2018 12:32:35 -0700 Subject: [PATCH 6/8] remove semi-colons --- index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index 981e8119c4..423dad8187 100644 --- a/index.d.ts +++ b/index.d.ts @@ -117,10 +117,10 @@ export const animated: { [Tag in keyof JSX.IntrinsicElements]: ComponentClass< JSX.IntrinsicElements[Tag] > -}; +} -type TransitionKeyProps = string | number; -type TransitionItemProps = string | number | object; +type TransitionKeyProps = string | number +type TransitionItemProps = string | number | object interface TransitionProps { /** From bd990553e2e2f990d62e1c2a1e305cb836a42131 Mon Sep 17 00:00:00 2001 From: Sydney Date: Tue, 24 Jul 2018 17:31:42 -0700 Subject: [PATCH 7/8] Third time's the charm Make the Omit type (the Pick<> Exclude<> combo) correctly omit the "to" property of springprops --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 423dad8187..e30a7c8418 100644 --- a/index.d.ts +++ b/index.d.ts @@ -242,7 +242,7 @@ export class Keyframes extends PureComponen ): (states: object) => (props: object) => Keyframes static Spring( states: object - ): (props: object) => Keyframes, Exclude, {to:DS}>>, DS> + ): (props: object) => Keyframes, Exclude, "to">>, DS> static Trail( states: object ): (props: object) => Keyframes, DS> From 18d16796a95afd19bbc3b234d59dc388609c1b7c Mon Sep 17 00:00:00 2001 From: Sydney Date: Tue, 24 Jul 2018 17:32:45 -0700 Subject: [PATCH 8/8] Don't be permissive with props Don't allow `to` on other props objects either --- index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index e30a7c8418..30f4eb3f3b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -245,8 +245,8 @@ export class Keyframes extends PureComponen ): (props: object) => Keyframes, Exclude, "to">>, DS> static Trail( states: object - ): (props: object) => Keyframes, DS> + ): (props: object) => Keyframes, Exclude, "to">>, DS> static Transition( states: object - ): (props: object) => Keyframes, DS> + ): (props: object) => Keyframes, Exclude, "to">>, DS> }