{"id":26804400,"url":"https://github.com/svecosystem/strip-types","last_synced_at":"2025-10-03T14:29:49.000Z","repository":{"id":283188938,"uuid":"947911159","full_name":"svecosystem/strip-types","owner":"svecosystem","description":"A type stripper for Svelte.","archived":false,"fork":false,"pushed_at":"2025-03-25T15:07:53.000Z","size":145,"stargazers_count":12,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-21T09:18:24.621Z","etag":null,"topics":["javascript","strip","svelte","svelte-typescript","ts-to-js","typescript"],"latest_commit_sha":null,"homepage":"https://www.npm.im/@svecosystem/strip-types","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/svecosystem.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-13T12:50:29.000Z","updated_at":"2025-04-20T02:43:57.000Z","dependencies_parsed_at":"2025-03-24T17:21:32.146Z","dependency_job_id":"555fe51c-982d-4b53-bb5c-3b3eb073c67f","html_url":"https://github.com/svecosystem/strip-types","commit_stats":null,"previous_names":["ieedan/sv-strip","svecosystem/strip-types"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svecosystem%2Fstrip-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svecosystem%2Fstrip-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svecosystem%2Fstrip-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/svecosystem%2Fstrip-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/svecosystem","download_url":"https://codeload.github.com/svecosystem/strip-types/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250372947,"owners_count":21419722,"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","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":["javascript","strip","svelte","svelte-typescript","ts-to-js","typescript"],"created_at":"2025-03-29T22:16:35.362Z","updated_at":"2025-10-03T14:29:43.943Z","avatar_url":"https://github.com/svecosystem.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @svecosystem/strip-types\n\n[![npm version](https://flat.badgen.net/npm/v/@svecosystem/strip-types?color=pink)](https://npmjs.com/package/@svecosystem/strip-types)\n[![npm downloads](https://flat.badgen.net/npm/dm/@svecosystem/strip-types?color=pink)](https://npmjs.com/package/@svecosystem/strip-types)\n[![license](https://flat.badgen.net/github/license/svecosystem/strip-types?color=pink)](https://github.com/svecosystem/strip-types/blob/main/LICENSE)\n[![](https://dcbadge.vercel.app/api/server/fdXy3Sk8Gq?style=flat)](https://discord.gg/fdXy3Sk8Gq)\n\nA type stripper for Svelte.\n\n```sh\npnpm install @svecosystem/strip-types\n```\n\n```ts\nimport { strip } from '@svecosystem/strip-types';\n\nconst ts = `\u003cscript lang=\"ts\"\u003e\n    let value = $state\u003cstring\u003e('');\n\u003c/script\u003e`\n\nconst js = strip(ts);\n```\n\n**In**\n\n```svelte\n\u003cscript lang=\"ts\"\u003e\n    type Foo = number\n\n    let value = $state\u003cFoo\u003e('');\n\u003c/script\u003e\n\n\u003cinput bind:value/\u003e\n```\n\n**Out**\n\n```svelte\n\u003cscript\u003e\n    let value = $state('');\n\u003c/script\u003e\n\n\u003cinput bind:value/\u003e\n```\n\n## Formatting\n\nBy default `@svecosystem/strip-types` will remove leading and trailing whitespace when removing nodes. This will result in an output that is correctly formatted (with a small performance penalty).\n\nIf you are doing your own formatting you can disable this behavior with the `format` option like so:\n```ts\nconst js = strip(ts, { format: false });\n```\n\n### Empty Script Tags\n\nEmpty script tags can be created as a side effect of removing types or because there was an empty script tag just to enable TypeScript for the template.\n\nIn any case they serve no use in the output code and will be removed by default. You can disable this behavior with the `removeEmptyScripts` option like so:\n```ts\nconst js = strip(ts, { removeEmptyScripts: false });\n```\n\n## Limitations\n\n### Formatting\n\nWhile `@svecosystem/strip-types` includes a `format` option it is not a formatter. It will do it's best to maintain the formatting of the original code when stripping types but it is still recommended to use your own formatter if possible.\n\n### Unsupported Syntax\n\n- ❌ Enums\n```ts\nenum Foo {\n    Bar\n}\n```\n- ❌ Constructor Parameter Properties\n```ts\nclass Foo {\n    // the access modifier (public) is not allowed\n    constructor(public bar) {\n\n    }\n}\n```\n\n## Contributing\n\nInstall dependencies:\n\n```sh\npnpm install\n```\n\nRun tests:\n\n```sh\npnpm test\n```\n\nAdd a changeset with your changes:\n```sh\npnpm changeset\n```\n\nFinally before you commit your changes run:\n\n```sh\npnpm format\n\npnpm check\n```\n\n### Tests\n\nIf you are contributing please make sure to include tests.\n\nAll the test cases can be found under `./tests/cases`.\n\nEach case is a folder with 2 files a `ts.svelte` and a `js.svelte`. `js.svelte` should be the stripped version of the `ts.svelte`. If you don't provide `js.svelte` then `vitest` will expect `strip` to error.\n\n**Example test case**\n```\ntests\n└── cases\n    ├── \u003cyour test name\u003e\n    │   ├── js.svelte\n    │   └── ts.svelte\n    └── ...\n```\n\n## License\n\nPublished under the [MIT](https://github.com/svecosystem/strip-types/blob/main/LICENSE) license.\nBuilt by [Aidan Bleser](https://github.com/ieedan) and [community](https://github.com/svecosystem/strip-types/graphs/contributors).\n\u003cbr\u003e\u003cbr\u003e\n\u003ca href=\"https://github.com/svecosystem/strip-types/graphs/contributors\"\u003e\n\u003cimg src=\"https://contrib.rocks/image?repo=svecosystem/strip-types\" /\u003e\n\u003c/a\u003e\n\n## Community\n\nJoin the Discord server to ask questions, find collaborators, or just say hi!\n\n\u003ca href=\"https://discord.gg/fdXy3Sk8Gq\" alt=\"Svecosystem Discord community\"\u003e\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://invidget.switchblade.xyz/fdXy3Sk8Gq\"\u003e\n  \u003cimg alt=\"Svecosystem Discord community\" src=\"https://invidget.switchblade.xyz/fdXy3Sk8Gq?theme=light\"\u003e\n\u003c/picture\u003e\n\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsvecosystem%2Fstrip-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsvecosystem%2Fstrip-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsvecosystem%2Fstrip-types/lists"}