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

Argument of type '{ parent: any, mode: "single"; }' is not assignable to parameter of type 'TextfitProps' #2

Closed
brunobely opened this issue Oct 27, 2021 · 3 comments

Comments

@brunobely
Copy link

I tried using the library like this:

<script lang="ts">
 import { textfit } from 'svelte-textfit';
 let parent;
</script>

<a bind:this={parent} href="#">
  <p use:textfit={{parent, mode:"single"}}><slot /></p>
</a>

And it resulted in the following error:

Argument of type '{ parent: any; mode: "single"; }' is not assignable to parameter of type 'TextfitProps'.
  Type '{ parent: any; mode: "single"; }' is missing the following properties from type 'TextfitProps': update, min, max, forceSingleModeWidth, and 8 more.ts(2345)

I also tried coercing type like <TextfitProps>{parent, mode:"single"} and ({parent, mode:"single"} as TextfitProps) but it doesn't seem like Svelte liked or understood it.

Any ideas?

@micha-lmxt
Copy link
Owner

That appears to be a Typescript error. Maybe it does not like the parent to be 'any'. Could you try to define the type in the script section? Like:

let parent : Node | undefined

Casting types outside of the script tag is not supported by Svelte at the moment afaik.

It is also complaining about missing properties, but since they are all optional it the complaint doesn't make a lot of sense to me. Which version of textfit so you have installed?

@yasserlens
Copy link

@micha-lmxt related to your response about the version installed: the most recent update that has all props being optional isn't accessible via npm install for some reason. npm install svelte-textfit@latest returns v.1.1.1, and trying to install 1.1.2 fails. Thanks for looking into this!

@micha-lmxt
Copy link
Owner

It is published to npm today, v1.1.3

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

No branches or pull requests

3 participants