Skip to content

Commit

Permalink
fix: remove infer S extends L (#1988)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaellis authored Sep 25, 2022
1 parent 9cf3bfe commit 2fad161
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"access": "public",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": []
"ignore": ["@react-spring/demo", "@react-spring/docs"]
}
16 changes: 16 additions & 0 deletions .changeset/cuddly-dolls-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@react-spring/core': patch
'@react-spring/animated': patch
'@react-spring/parallax': patch
'@react-spring/rafz': patch
'react-spring': patch
'@react-spring/shared': patch
'@react-spring/types': patch
'@react-spring/konva': patch
'@react-spring/native': patch
'@react-spring/three': patch
'@react-spring/web': patch
'@react-spring/zdog': patch
---

fix: allow transpile from TS < 4.7
21 changes: 21 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"mode": "pre",
"tag": "beta",
"initialVersions": {
"@react-spring/demo": "0.0.1",
"@react-spring/docs": "1.0.7",
"@react-spring/animated": "9.5.4",
"@react-spring/core": "9.5.4",
"@react-spring/parallax": "9.5.4",
"@react-spring/rafz": "9.5.4",
"react-spring": "9.5.4",
"@react-spring/shared": "9.5.4",
"@react-spring/types": "9.5.4",
"@react-spring/konva": "9.5.4",
"@react-spring/native": "9.5.4",
"@react-spring/three": "9.5.4",
"@react-spring/web": "9.5.4",
"@react-spring/zdog": "9.5.4"
},
"changesets": []
}
36 changes: 21 additions & 15 deletions packages/core/src/hooks/useSpring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ import { useSprings } from './useSprings'
* The props that `useSpring` recognizes.
*/
export type UseSpringProps<Props extends object = any> = unknown &
PickAnimated<Props> extends infer State extends Lookup<any>
? Remap<
ControllerUpdate<State> & {
/**
* Used to access the imperative API.
*
* When defined, the render animation won't auto-start.
*/
ref?: SpringRef<State>
}
>
PickAnimated<Props> extends infer State
? State extends Lookup
? Remap<
ControllerUpdate<State> & {
/**
* Used to access the imperative API.
*
* When defined, the render animation won't auto-start.
*/
ref?: SpringRef<State>
}
>
: never
: never

/**
Expand All @@ -32,8 +34,10 @@ export function useSpring<Props extends object>(
| Function
| (() => (Props & Valid<Props, UseSpringProps<Props>>) | UseSpringProps),
deps?: readonly any[] | undefined
): PickAnimated<Props> extends infer State extends Lookup<any>
? [SpringValues<State>, SpringRef<State>]
): PickAnimated<Props> extends infer State
? State extends Lookup
? [SpringValues<State>, SpringRef<State>]
: never
: never

/**
Expand All @@ -49,8 +53,10 @@ export function useSpring<Props extends object>(
export function useSpring<Props extends object>(
props: (Props & Valid<Props, UseSpringProps<Props>>) | UseSpringProps,
deps: readonly any[] | undefined
): PickAnimated<Props> extends infer State extends Lookup<any>
? [SpringValues<State>, SpringRef<State>]
): PickAnimated<Props> extends infer State
? State extends Lookup
? [SpringValues<State>, SpringRef<State>]
: never
: never

/** @internal */
Expand Down
12 changes: 8 additions & 4 deletions packages/core/src/hooks/useSprings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ export function useSprings<Props extends UseSpringProps>(
length: number,
props: (i: number, ctrl: Controller) => Props,
deps?: readonly any[]
): PickAnimated<Props> extends infer State extends Lookup<any>
? [SpringValues<State>[], SpringRefType<State>]
): PickAnimated<Props> extends infer State
? State extends Lookup<any>
? [SpringValues<State>[], SpringRefType<State>]
: never
: never

/**
Expand All @@ -62,8 +64,10 @@ export function useSprings<Props extends UseSpringsProps>(
length: number,
props: Props[] & UseSpringsProps<PickAnimated<Props>>[],
deps: readonly any[] | undefined
): PickAnimated<Props> extends infer State extends Lookup<any>
? [SpringValues<State>[], SpringRefType<State>]
): PickAnimated<Props> extends infer State
? State extends Lookup<any>
? [SpringValues<State>[], SpringRefType<State>]
: never
: never

/** @internal */
Expand Down
12 changes: 8 additions & 4 deletions packages/core/src/hooks/useTrail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ export function useTrail<Props extends object>(
ctrl: Controller
) => UseTrailProps | (Props & Valid<Props, UseTrailProps<Props>>),
deps?: readonly any[]
): PickAnimated<Props> extends infer State extends Lookup<any>
? [SpringValues<State>[], SpringRef<State>]
): PickAnimated<Props> extends infer State
? State extends Lookup<any>
? [SpringValues<State>[], SpringRef<State>]
: never
: never

export function useTrail<Props extends object>(
Expand All @@ -32,8 +34,10 @@ export function useTrail<Props extends object>(
length: number,
props: UseTrailProps | (Props & Valid<Props, UseTrailProps<Props>>),
deps: readonly any[]
): PickAnimated<Props> extends infer State extends Lookup<any>
? [SpringValues<State>[], SpringRef<State>]
): PickAnimated<Props> extends infer State
? State extends Lookup<any>
? [SpringValues<State>[], SpringRef<State>]
: never
: never

export function useTrail(
Expand Down
12 changes: 8 additions & 4 deletions packages/core/src/hooks/useTransition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ export function useTransition<Item, Props extends object>(
| UseTransitionProps<Item>
| (Props & Valid<Props, UseTransitionProps<Item>>),
deps?: any[]
): PickAnimated<Props> extends infer State extends Lookup
? [TransitionFn<Item, PickAnimated<Props>>, SpringRefType<State>]
): PickAnimated<Props> extends infer State
? State extends Lookup
? [TransitionFn<Item, PickAnimated<Props>>, SpringRefType<State>]
: never
: never

export function useTransition<Item, Props extends object>(
Expand All @@ -62,8 +64,10 @@ export function useTransition<Item, Props extends object>(
| UseTransitionProps<Item>
| (Props & Valid<Props, UseTransitionProps<Item>>),
deps: any[] | undefined
): PickAnimated<Props> extends infer State extends Lookup
? [TransitionFn<Item, State>, SpringRefType<State>]
): PickAnimated<Props> extends infer State
? State extends Lookup
? [TransitionFn<Item, State>, SpringRefType<State>]
: never
: never

export function useTransition(
Expand Down

0 comments on commit 2fad161

Please sign in to comment.