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

svelte-check complaints against type of correct style attribute on SVG elements #345

Closed
adamansky opened this issue Jul 24, 2020 · 1 comment
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release. good first issue Good for newcomers

Comments

@adamansky
Copy link

adamansky commented Jul 24, 2020

Describe the bug

svelte-check complaints against type of correct style attribute on SVG elements.
Example:

<svg
    width={size}
    height={size}
    viewBox="0 0 {iconSvg.viewbox} {iconSvg.viewbox}"
    class={`icon ${status} ${$$props.class || ''}`}
    style={$$props.style || null}>
    <g>
      {#each iconSvg.paths as p}
         <path style={p.color || color ? `fill:${p.color || color}` : undefined}
               d={p.path} />
      {/each}
    </g>
</svg>

Here string is the actual type of style attribute of path element.
We have the following svelte-check error:

Error: Type 'string | undefined' is not assignable to type 'CSSProperties | undefined'.
  Type 'string' is not assignable to type 'CSSProperties | undefined'. (ts)
    <path style={p.color 

I suppose this caused by incorrect definition of SVGAttributes (svelte2tsx/svelte-jsx.d.ts)

    interface SVGAttributes<T> extends DOMAttributes<T> {
      // Attributes which also defined in HTMLAttributes
      ....
      name?: string;
      style?: CSSProperties;  <---
      target?: string;
      type?: string;
      width?: number | string;
@adamansky adamansky added the bug Something isn't working label Jul 24, 2020
@jasonlyu123 jasonlyu123 added the good first issue Good for newcomers label Jul 24, 2020
@jasonlyu123
Copy link
Member

Yeah, it should be string. CSSProperties doesn't work

This was referenced Jul 24, 2020
dummdidumm pushed a commit that referenced this issue Jul 27, 2020
* fix style svg attribute #345

* fix svg style

* remove CSSProperties from html attributes

* remove CSSProperties interface
@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release. good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants