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

Export transition interfaces so they can be used and extended #5207

Closed
Kruhlmann opened this issue Jul 25, 2020 · 2 comments · Fixed by #5221
Closed

Export transition interfaces so they can be used and extended #5207

Kruhlmann opened this issue Jul 25, 2020 · 2 comments · Fixed by #5221

Comments

@Kruhlmann
Copy link

Kruhlmann commented Jul 25, 2020

Is your feature request related to a problem? Please describe.

I'd like to be able to import the transition interfaces defined in https://github.com/sveltejs/svelte/blob/master/src/runtime/transition/index.ts

This would be useful, in my case, for creating transitions which use the same parameters as one of the existing transitions.

I was creating a new sliding animation which happened to use the same parameters defined in the existing SlideParams interface. My solution was to simply re-define this interface in my source, which is inelegant:

import { cubicOut } from "svelte/easing";
import { TransitionConfig } from "svelte/types/runtime/transition";

type EasingFunction = (time: number) => number;

interface SlideParams {
    delay?: number;
    duration?: number;
    easing?: EasingFunction;
}

export function my_custom_sliding_transition(
    node: Element,
    { delay = 0, duration = 400, easing = cubicOut }: SlideParams,
): TransitionConfig {
    //...
}

Ideal:

import { cubicOut } from "svelte/easing";
import {
    TransitionConfig,
    SlideParams,
    EasingFunction
} from "svelte/types/runtime/transition";

export function my_custom_sliding_transition(
    node: Element,
    { delay = 0, duration = 400, easing = cubicOut }: SlideParams,
): TransitionConfig {
    //...
}

Describe the solution you'd like
A isolution would be to simply prefix the existing interfaces with export.

Describe alternatives you've considered

How important is this feature to you?
It has no functional purpose so it is not very important, it would simply make code more elegant, and avoid dupplicating code.

Additional context
I can create the merge request myself, but I'd rather wait too see if I missed something stupid, which solves my problem, before creating it.

@umanghome
Copy link
Contributor

I've needed this once too. Had to look at the source code to figure out types. I'm making a PR to change this.

@Kruhlmann
Copy link
Author

Perfect!

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.

3 participants