tabler-icons icon indicating copy to clipboard operation
tabler-icons copied to clipboard

Fix `TablerIconProps` type definition

Open haines opened this issue 3 years ago • 1 comments

Fixes #294

Extending an interface implies that a value of the subtype can be assigned to the supertype, but TablerIconProps can't be assigned to SVGAttributes<SVGElement> because the stroke property is incompatible (because it is actually used to set the strokeWidth).

Instead, this PR uses Omit to remove the overridden properties from the base type and adds them to the props by referencing the type of the SVG attributes that they ultimately are used to set. This approach has the advantage of guaranteeing that these property types are consistent with React (in particular, they explicitly allow undefined, which is needed with exactOptionalPropertyTypes).

haines avatar Sep 16 '22 11:09 haines

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
tabler-icons ✅ Ready (Inspect) Visit Preview Sep 16, 2022 at 11:06AM (UTC)

vercel[bot] avatar Sep 16 '22 11:09 vercel[bot]

@haines thank you so much! ❤️

codecalm avatar Sep 21 '22 20:09 codecalm