[fix] more specific return type for crossfade (#6927)

People with "noUncheckedIndexedAccess" set to true in their tsconfig would get false errors when accessing the return type because without this specific tuple typing, TS infers the return type as being an array of functions, not a tuple of functions.
Fixes #6926
pull/7738/head
Simon H 5 years ago committed by GitHub
parent 8293bc3b51
commit 00e6b61f05

@ -3,6 +3,7 @@
## Unreleased
* Fix overly restrictive preprocessor types ([#6904](https://github.com/sveltejs/svelte/pull/6904))
* More specific typing for crossfade function - returns a tuple, not an array ([#6926](https://github.com/sveltejs/svelte/issues/6926))
## 3.44.1

@ -212,7 +212,20 @@ type ClientRectMap = Map<any, { rect: ClientRect }>;
export function crossfade({ fallback, ...defaults }: CrossfadeParams & {
fallback?: (node: Element, params: CrossfadeParams, intro: boolean) => TransitionConfig;
}) {
}): [
(
node: Element,
params: CrossfadeParams & {
key: any;
}
) => () => TransitionConfig,
(
node: Element,
params: CrossfadeParams & {
key: any;
}
) => () => TransitionConfig
] {
const to_receive: ClientRectMap = new Map();
const to_send: ClientRectMap = new Map();

Loading…
Cancel
Save