Một mục tập trung giao diện trong kho dữ liệu GitHub của TopGit: carbon-design-system/sveld, 455 sao, nhóm Frontend, TypeScript. Generate TypeScript definitions and component documentation for your Svelte components
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
sveld generates TypeScript definitions and component documentation (JSON and Markdown) for Svelte component libraries. It statically analyzes props, events, slots, snippets, context, module exports, and rest props, and reads JSDoc where inference isn't enough.
The generated .d.ts files give consumers autocomplete and type checking through the Svelte Language Server and TypeScript, with little effort from the library author. Carbon Components Svelte uses sveld to generate its component types and API metadata.
sveld supports Svelte 3, Svelte 4, Svelte 5 without runes (export let, <slot>, $$restProps), and Svelte 5 runes ($props(), $bindable(), {@render}, callback props).
When to use sveld
If your library is built with SvelteKit's svelte-package, it already emits .d.ts files through svelte2tsx; start there.
sveld is for:
JavaScript-first libraries. Components written in plain JavaScript with JSDoc, where you want full editor types without converting to lang="ts".
Docs from the same source as the types. JSON and Markdown API docs, generated in the same run.
API drift checks.--check diffs the component API against a committed snapshot and fails CI on breaking changes.
Richer types from JSDoc.@typedef, @callback, @slot, @event, and context types that plain inference can't produce.
lang="ts" components work too: sveld keeps their type annotations as written.
Install
npm i -D sveld
# or: pnpm i -D sveld / bun i -D sveld / yarn add -D sveld
Quick start
sveld reads the "svelte" field of your package.json as the entry point: the file that re-exports your components.
{
"svelte": "./src/index.js"
}
CLI
npx sveld # writes types/*.d.ts
npx sveld --json --markdown # also writes COMPONENT_API.json and COMPONENT_INDEX.md
Run npx sveld --help for every flag. Options can also live in a sveld.config.js:
document is the same component API document json: true writes, so you can render your own formats from it. See Options for everything sveld() accepts and returns.
Example
Given this component:
<!-- Button.svelte -->
<script>
export let type = "button";
export let primary = false;
</script>
<button {...$$restProps} {type} class:primary on:click>
<slot>Click me</slot>
</button>
sveld infers prop types and defaults, the forwarded click event, the default slot, and the rest props spread onto <button>:
The default slot is also typed as a children snippet prop for Svelte 5 consumers, and the data-* index signature lets callers pass data attributes through $$restProps.
Add JSDoc to tighten types and add descriptions:
<script>
/** @type {"button" | "submit" | "reset"} */
export let type = "button";
/**
* Set to `true` to use the primary variant
*/
export let primary = false;
</script>
type $Props = {
/**
* @default "button"
*/
type?: "button" | "submit" | "reset";
/**
* Set to `true` to use the primary variant
* @default false
*/
primary?: boolean;
children?: (this: void) => void;
[key: `data-${string}`]: unknown;
};
The runes version (let { type = "button", primary = false, children, ...rest } = $props(), spreading rest and rendering children) produces the same $Props. It has no click event, since runes components take onclick as a prop through rest.
The .d.ts extends SvelteComponentTyped by default, which works for consumers on Svelte 3, 4, and 5. Set typesOptions.format: "component" (--types-format=component) to emit the Svelte 5 Component type instead. See Output.
JSON and Markdown
npx sveld --markdown documents the same component in COMPONENT_INDEX.md:
## `Button`
### Props
| Prop name | Required | Kind | Reactive | Binding | Type | Default value | Description |
| :- | :- | :- | :- | :- | :- | :- | :- |
| type | No | <code>let</code> | No | -- | <code>"button" | "submit" | "reset"</code> | <code>"button"</code> | -- |
| primary | No | <code>let</code> | No | -- | <code>boolean</code> | <code>false</code> | Set to `true` to use the primary variant |
### Slots
| Slot name | Default | Props | Fallback | Description |
| :- | :- | :- | :- | :- |
| -- | Yes | <code>Record<string, never> </code> | <code>Click me</code> | -- |
### Events
| Event name | Type | Detail | Description |
| :- | :- | :- | :- |
| click | forwarded | -- | -- |
npx sveld --json writes the same data to COMPONENT_API.json, validated by a JSON Schema that ships with the package. An excerpt of the prop entry:
Commit COMPONENT_API.json, then gate pull requests on API changes and inference gaps:
npx sveld --check # exit 3 on a breaking API change against the snapshot
npx sveld --strict # exit 4 when a prop fell back to `any`, a tag was dropped, ...
carbon-design-system/sveld có 455 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/carbon-design-system/sveld. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
carbon-design-system/sveld có những chủ đề gì?
GitHub topics của carbon-design-system/sveld: "docgen", "documentation", "jsdoc", "svelte", "svelte-component", "typescript-definitions". TopGit xếp repo vào nhóm Frontend.
carbon-design-system/sveld còn đang phát triển không?
Commit gần nhất trên carbon-design-system/sveld là 4 ngày trước (theo timestamp GitHub). Repo có 23 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
carbon-design-system/sveld viết bằng ngôn ngữ gì?
carbon-design-system/sveld chủ yếu viết bằng TypeScript. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Cùng nhóm Frontend còn repo nào?
carbon-design-system/sveld thuộc nhóm Frontend trên TopGit, cùng 6 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về carbon-design-system/sveld ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/carbon-design-system/sveld là nguồn chính thức.
Vì sao carbon-design-system/sveld được xếp vào nhóm Frontend?
TopGit xếp carbon-design-system/sveld vào nhóm Frontend dựa trên GitHub topics và mô tả của repo (gắn thẻ: "docgen", "documentation", "jsdoc"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về sveld?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về sveld.