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

Consider exporting FlipParams interface from "svelte/animate" #7103

Closed
metonym opened this issue Jan 5, 2022 · 1 comment · Fixed by #7104
Closed

Consider exporting FlipParams interface from "svelte/animate" #7103

metonym opened this issue Jan 5, 2022 · 1 comment · Fixed by #7104

Comments

@metonym
Copy link
Contributor

metonym commented Jan 5, 2022

Describe the bug

For my use case, I would like to export a prop to customize the animate:flip directive.

<script lang="ts">
  import { flip } from "svelte/animate";

  export let flipParams = {};
</script>

<div animate:flip={flipParams} />

The desired UX is to re-use the FlipParams interface for typing the prop. However, FlipParams is currently not exported from types/runtime/animate/index.d.ts.

<script lang="ts">
  import { flip } from "svelte/animate";
  import type { FlipParams } from "svelte/animate";

  export let flipParams: FlipParams = {};
</script>

My current workaround is to pick properties from the AnimationConfig interface:

<script lang="ts">
  import { flip } from "svelte/animate";
  import type { AnimationConfig } from "svelte/animate";

  export let flipParams: Pick<AnimationConfig, "delay" | "duration" | "easing"> = {};
</script>

<div animate:flip={flipParams} />

Reproduction

N/A

Logs

No response

System Info

System:
    OS: macOS 11.6
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 1.27 GB / 32.00 GB
    Shell: 5.8 - /usr/local/bin/zsh
  Binaries:
    Node: 14.16.0 - ~/.nvm/versions/node/v14.16.0/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 7.21.1 - ~/.nvm/versions/node/v14.16.0/bin/npm
  Browsers:
    Chrome: 96.0.4664.110
    Firefox: 94.0.1
    Safari: 14.1.2

Severity

annoyance

@asolove
Copy link

asolove commented Jan 14, 2022

Exporting the type is a great option if the project is willing to do that and have it be part of public import surface.

If you need to work around this and access the type right now, however, I think you could use the TypeScript inference hack to "pull" the option types out of the flip function and give them a local type name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants