Error: Expected 2 arguments, but got 1. (ts) for <div transition:fade >
See original GitHub issueSince svelte-check 1.1.29 the transition shorthand <div transition:fade>
incorrectly reports the
Error: Expected 2 arguments, but got 1.
error.
When using the shorthand notation, svelte calls the fade (or any other function) with 2 arguments, the element and an empty object. REPL
To Reproduce
<script lang="ts">
import { fade } from "svelte/transition";
let visible = true;
function toggle() {
visible = !visible;
}
</script>
<button on:click={toggle}>Toggle</button>
{#if visible}
<div transition:fade>Fades in and out</div>
{/if}
Demo: https://github.com/bfanger/svelte-check-transition-bug
The failed run: https://github.com/bfanger/svelte-check-transition-bug/runs/1783108223?check_suite_focus=true
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
Expected 2 arguments, but got 1.ts(2554) - Stack Overflow
I think you have 2 ways to resolve this problem. 1: Your input to function login is not correct login() { const user...
Read more >Svelte Tutorials Learning Notes: Transitions
The function takes two arguments, t and (optional) u , where u === 1 - t . At intro (eg. fade in), t...
Read more >CSSTransition Component - React Transition Group
CSSTransition applies a pair of class names during the appear , enter , and exit states of the transition. The first class is...
Read more >Getting Started With Animations For Angular: Fade + FadeSlide
An animation step for an element can also be added by using the animate() function. This function has two arguments: the duration (milliseconds) ......
Read more >In-Depth guide into animations in Angular - InDepth.Dev
animate - specifies the duration and any additional CSS animation properties such as easing. style , transition , and animate accept both ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A fallback for older Svelte versions is now available which should silence the error.
I can’t predict what svelte compiler will do in the future, but right now it adds the {} iwhen there are no explicit parameters. Im not sure if that behavior is the same for all shorthands notations.