question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Expected 2 arguments, but got 1. (ts) for <div transition:fade >

See original GitHub issue

Since 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:closed
  • Created 3 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
dummdidummcommented, Feb 2, 2021

A fallback for older Svelte versions is now available which should silence the error.

0reactions
bfangercommented, Jan 29, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found