v0.21.0
Breaking Changes
Fixes
- prefix internal
RestProps
type with$
to avoid conflicts withRest.svelte
as a component name (9534dd4, #148)
The strategy to generating types for exported props has changed. Previously, a TypeScript error would occur for a scenario in which ComponentProps
would incorrectly extend RestProps
.
Before
type $RestProps = SvelteHTMLElements["ul"] & SvelteHTMLElements["ol"];
// ❌ TypeScript expresses an error because `type` is a native attribute on `ul` and `ol` elements.
export interface ComponentProps extends $RestProps {
type: "ordered" | "unordered";
}
The solution is to do the following:
- Use a type alias instead of interface for exported component props.
- Omit keys in component props from
RestProps
. - Exported component props is the intersection of
RestProps
(omitting component prop keys) and component props.
After
type $RestProps = SvelteHTMLElements["ul"] & SvelteHTMLElements["ol"];
type $Props = {
type: "ordered" | "unordered";
}
// ✅ ComponentProps combines `RestProps` with `$Props`, omitting the custom `type` prop from `$RestProps`.
export type ComponentProps = Omit<$RestProps, keyof $Props> & $Props;