Skip to content

Releases: carbon-design-system/sveld

v0.22.0

10 Nov 23:16
Compare
Choose a tag to compare

Breaking Changes

  • upgrade prettier to v3 (by default, trailingComma is now "all") (11d086e, #133)

v0.21.0

27 Oct 22:28
Compare
Choose a tag to compare

Breaking Changes

  • use type alias instead of interface for exported component props type (d9cf04a, #138)

Fixes

  • prefix internal RestProps type with $ to avoid conflicts with Rest.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;

v0.20.3

25 Oct 19:20
Compare
Choose a tag to compare

Fixes

  • use WindowEventMap for cut/copy/paste events (cfe753f, #143)

v0.20.2

13 Sep 18:57
Compare
Choose a tag to compare

Fixes

  • reduce dependencies by upgrading svelte-preprocess from v5 to v6

v0.20.1

12 Sep 20:17
Compare
Choose a tag to compare

Fixes

  • reduce dependencies by replacing fast-glob with tinyglobby

v0.20.0

20 Apr 21:31
Compare
Choose a tag to compare

Features

  • support component generics via the custom @generics tag

Currently, to define generics for a Svelte component, you must use generics attribute on the script tag. Note that this feature is experimental and may change in the future.

However, the generics attribute only works if using lang="ts"; the language server will produce an error if generics is used without specifying lang="ts".

<!-- This causes an error because `lang="ts"` must be used. -->
<script generics="Row extends DataTableRow = any"></script>

Because sveld is designed to support JavaScript-only usage as a baseline, the API design to specify generics uses a custom JSDoc tag @generics.

Signature:

/**
 * @generics {GenericParameter} GenericName
 */

Example

/**
 * @generics {Row extends DataTableRow = any} Row
 */

The generated TypeScript definition will resemble the following:

export default class Component<Row extends DataTableRow = any> extends SvelteComponentTyped<
  ComponentProps<Row>,
  Record<string, any>,
  Record<string, any>
> {}

v0.19.2

09 Apr 00:05
Compare
Choose a tag to compare

Fixes

  • ComponentParser should remove carriage returns (Windows)

This package is now published with provenance.

v0.19.1

18 Oct 03:43
Compare
Choose a tag to compare

Fixes

  • only print outFile when writing Markdown file (#110)
  • upgrade svelte-preprocess and typescript to ameliorate peer dependency warning (#111)

v0.19.0

19 Jul 16:00
Compare
Choose a tag to compare

Breaking Changes

  • if using Svelte 3, the generated TypeScript definitions now require version 3.55 or higher

Features

  • support Svelte 4 in the generated TypeScript definitions (#109)

v0.18.1

04 Jun 16:46
Compare
Choose a tag to compare

Fixes