You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today, I encountered a bug because the component was passed a string ("300") instead of a number (300) or a properly formatted string ("300px"). This error went unnoticed because width and height attributes are currently typed as number | string | undefined.
While I understand that implementing stricter typing could break older code (refer to #1179 (comment)), I believe that the value of TypeScript lies in providing strict, safe typing to prevent potential type errors.
Therefore, i propose we make the type for width and height more strict like as said in #1179 using template literal types.
type Length = number | `${number}${'px'|'cm'|'mm'|'em'}`
I am open to creating a PR for this issue.
The text was updated successfully, but these errors were encountered:
This is a continuation of #1179.
Today, I encountered a bug because the
component was passed a string (
"300"
) instead of a number (300
) or a properly formatted string ("300px"
). This error went unnoticed because width and height attributes are currently typed asnumber | string | undefined
.While I understand that implementing stricter typing could break older code (refer to #1179 (comment)), I believe that the value of TypeScript lies in providing strict, safe typing to prevent potential type errors.
Therefore, i propose we make the type for
width
andheight
more strict like as said in #1179 using template literal types.I am open to creating a PR for this issue.
The text was updated successfully, but these errors were encountered: