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

fix: Parameters with default values are optional #5083

Merged
merged 1 commit into from
Jul 7, 2020

Conversation

bfanger
Copy link
Contributor

@bfanger bfanger commented Jun 28, 2020

I've marked the properties of parameters that have default values as optional (x: number to x?: number)

The current situation marks the properties of the interface as required, which cause errors when properties are omitted:
screenshot

Argument of type '{ x: number; }' is not assignable to parameter of type 'FlyParams'.
Type '{ x: number; }' is missing the following properties from type 'FlyParams': delay, duration, easing, y, opacity

@dkzlv
Copy link
Contributor

dkzlv commented Jun 30, 2020

@bfanger As far as I understand your solution would still require the developer to pass an empty object to all these animation functions like this: transition:fade={{}}.

In order to make it completely compatible to the real interface we need to make the argument itself an optional one.

@bfanger bfanger force-pushed the feature/optional-params branch from ea90067 to ecf81b9 Compare June 30, 2020 19:33
@bfanger bfanger force-pushed the feature/optional-params branch from ecf81b9 to 812a809 Compare June 30, 2020 19:43
@bfanger
Copy link
Contributor Author

bfanger commented Jun 30, 2020

@dkzlv <div transition:fly> already worked without errors, I first thought this was a feature/hack of the language-server and changed the second parameter to optional, but i've reverted that change. As it turns out, when you don't provide a value for a transition svelte will call the function with an empty object as 2nd parameter.

<div transition:fly> is shorthand for <div transition:fly={{}}>

@Conduitry Conduitry merged commit 3dfb178 into sveltejs:master Jul 7, 2020
@Conduitry
Copy link
Member

The fixed types have been published in 3.24.0.

hontas added a commit to hontas/svelte that referenced this pull request Jul 18, 2020
* upstream/master: (190 commits)
  invalidate $$props and $$restProps only when there are changes (sveltejs#5123)
  site: use https in link in blog (sveltejs#5148)
  Simplify each block bindings example (sveltejs#5094)
  fix $$props reactive for slots (sveltejs#5125)
  site: add FAQ entry for how to document a svelte component (sveltejs#5131)
  site: remove an obsolete TODO in blog post (sveltejs#5135)
  Increase timeout for unit build
  Increase timeout for unit tests
  -> v3.24.0
  spread condition for input element (sveltejs#5004)
  update changelog
  fix(5018): compare wholeText instead of data (sveltejs#5028)
  html anchor in head (sveltejs#5071)
  error on expression scope store (sveltejs#5079)
  update changelog
  preprocess self-closing script and style tags (sveltejs#5082)
  update changelog
  fix: Parameters with default values are optional (sveltejs#5083)
  make builds time out after a reasonable period (sveltejs#5100)
  site: fix blog typo (sveltejs#5090)
  ...
taylorzane pushed a commit to taylorzane/svelte that referenced this pull request Dec 17, 2020
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 this pull request may close these issues.

3 participants