{"id":20631824,"url":"https://github.com/andrelmlins/svelte-dts","last_synced_at":"2025-10-12T11:39:20.468Z","repository":{"id":40632335,"uuid":"340778363","full_name":"andrelmlins/svelte-dts","owner":"andrelmlins","description":"Typescript declaration generator for svelte with typescript","archived":false,"fork":false,"pushed_at":"2022-04-06T01:37:22.000Z","size":96,"stargazers_count":28,"open_issues_count":3,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-19T21:19:05.346Z","etag":null,"topics":["cli","declaration-typescript","generator","rollup","svelte","transpiler","typscript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrelmlins.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-20T23:46:22.000Z","updated_at":"2024-06-25T23:31:20.000Z","dependencies_parsed_at":"2022-07-14T23:00:33.363Z","dependency_job_id":null,"html_url":"https://github.com/andrelmlins/svelte-dts","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/andrelmlins/svelte-dts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrelmlins%2Fsvelte-dts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrelmlins%2Fsvelte-dts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrelmlins%2Fsvelte-dts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrelmlins%2Fsvelte-dts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrelmlins","download_url":"https://codeload.github.com/andrelmlins/svelte-dts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrelmlins%2Fsvelte-dts/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267973343,"owners_count":24174402,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","declaration-typescript","generator","rollup","svelte","transpiler","typscript"],"created_at":"2024-11-16T14:13:38.428Z","updated_at":"2025-10-12T11:39:20.372Z","avatar_url":"https://github.com/andrelmlins.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Svelte dts\n\n[![npm version](https://badge.fury.io/js/svelte-dts.svg)](https://www.npmjs.com/package/svelte-dts) \u0026bull; [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/andrelmlins/svelte-dts/blob/master/LICENSE) \u0026bull; [![Node.js CI](https://github.com/andrelmlins/svelte-dts/workflows/Node.js%20CI/badge.svg)](https://github.com/andrelmlins/svelte-dts/actions?query=workflow%3A%22Node.js+CI%22)\n\nTypescript declaration generator for svelte with typescript. Create the declaration files for your library and project. These are the main characteristics of this library:\n\n✨ CLI(Command-line interface)\n\u003cbr /\u003e\n✨ Rollup plugin\n\u003cbr /\u003e\n✨ Svelte and typescript files\n\n## How it works?\n\nThe `svelte-dts` interpret the properties, events and slot properties in the svelte code, using typescript and svelte compiler. The `svelte-dts` too interpret typescript and declaration typescript code, and create default declarations for javascript code.\n\nObserve the code of the `click-counter-button` library that has the `ClickCounterButton` component:\n\n```html\n\u003cscript lang=\"ts\"\u003e\n  import { createEventDispatcher } from 'svelte';\n\n  export let initialNumber: number = 0;\n\n  let dispatch = createEventDispatcher\u003c{ change: number }\u003e();\n  let number = initialNumber;\n\n  $: dispatch('change', number);\n\u003c/script\u003e\n\n\u003cbutton on:click={() =\u003e (number += 1)}\u003eCliques: {number}\u003c/button\u003e\n```\n\nThe result is the generated typescript declarations. Please note below:\n\n```ts\nimport { SvelteComponentTyped } from 'svelte';\n\ndeclare module 'click-counter-button' {\n  interface ClickCounterButtonProps {\n    initialNumber: number;\n  }\n\n  class ClickCounterButton extends SvelteComponentTyped\u003cClickCounterButtonProps, { change: CustomEvent\u003cnumber\u003e }, {}\u003e {}\n\n  export default ClickCounterButton;\n}\n```\n\n## Installation\n\n```\nnpm i svelte-dts\n// OR\nyarn add svelte-dts\n```\n\n## Using with rollup\n\n```js\nimport typescript from '@rollup/plugin-typescript';\nimport svelte from 'rollup-plugin-svelte';\nimport autoPreprocess from 'svelte-preprocess';\nimport svelteDts from 'svelte-dts';\n\nexport default [\n  {\n    input: 'src/lib/App.svelte',\n    external: ['svelte/internal'],\n    plugins: [svelteDts(), svelte({ preprocess: autoPreprocess() }), typescript()],\n  },\n];\n```\n\n### Options\n\n| Option       | Type       | Description              | Default                  |\n| ------------ | ---------- | ------------------------ | ------------------------ |\n| `output`     | `string`   | Declarations output file | The value of `pkg.types` |\n| `extensions` | `string[]` | Valid Extensions         | .svelte, .ts, .js        |\n\n## Using with cli\n\n```sh\nsvelte-dts -i src/index.ts -o dist/index.d.ts\n```\n\n### Options\n\n| Option                                 | Alias           | Description              |\n| -------------------------------------- | --------------- | ------------------------ |\n| \u003ccode\u003e--input [input]\u003c/code\u003e           | \u003ccode\u003e-i\u003c/code\u003e | App input file           |\n| \u003ccode\u003e--output [output]\u003c/code\u003e         | \u003ccode\u003e-o\u003c/code\u003e | Declarations output file |\n| \u003ccode\u003e--extensions [extensions]\u003c/code\u003e | \u003ccode\u003e-e\u003c/code\u003e | Valid Extensions         |\n\n## NPM Statistics\n\nDownload stats for this NPM package\n\n[![NPM](https://nodei.co/npm/svelte-dts.png)](https://nodei.co/npm/svelte-dts/)\n\n## License\n\nSvelte dts is open source software [licensed as MIT](https://github.com/andrelmlins/svelte-dts/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrelmlins%2Fsvelte-dts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrelmlins%2Fsvelte-dts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrelmlins%2Fsvelte-dts/lists"}