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

Incomplete typings - measurements should accept percentages #1306

Closed
cyberwombat opened this issue Jul 26, 2023 · 3 comments
Closed

Incomplete typings - measurements should accept percentages #1306

cyberwombat opened this issue Jul 26, 2023 · 3 comments

Comments

@cyberwombat
Copy link

Bug report

I am converting project to TS and in my case the rect method doesn't accept percentages.

 const element = svg.rect('100%', '100%') 

Yields a TS error of "Agument of type 'string' is not assignable to parameter of type 'number'."
I can make a fiddle if necessary but I think it's pretty clear. The TS definitions for all the shapes should accept strings as well.

@elliottmejia
Copy link

Triangle in a square hole!

I'm sure you're aware, but you can instead use a relative dimensional calculation if you're stuck on this. Pain in the butt, though, they should fix this to match JS.

const svgWidth = svg.viewbox().width;
const svgHeight = svg.viewbox().height;

const element = svg.rect(svgWidth, svgHeight);

@cyberwombat
Copy link
Author

Thanks that's a nice workaround. Was gonna extend the typings locally but struggling a bit with it so gonna use your suggestion

@Fuzzyma
Copy link
Member

Fuzzyma commented Sep 2, 2023

fixed in 3f623a9

@Fuzzyma Fuzzyma closed this as completed Sep 2, 2023
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