{"id":13457618,"url":"https://github.com/wheatjs/vite-plugin-vue-type-imports","last_synced_at":"2025-04-04T12:07:21.621Z","repository":{"id":37337186,"uuid":"423046024","full_name":"wheatjs/vite-plugin-vue-type-imports","owner":"wheatjs","description":"Import types in Vue SFC for defineProps","archived":false,"fork":false,"pushed_at":"2024-02-13T16:42:47.000Z","size":298,"stargazers_count":223,"open_issues_count":14,"forks_count":18,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-04T12:04:47.364Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wheatjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2021-10-31T03:46:39.000Z","updated_at":"2025-01-14T11:49:30.000Z","dependencies_parsed_at":"2024-10-22T15:15:12.528Z","dependency_job_id":null,"html_url":"https://github.com/wheatjs/vite-plugin-vue-type-imports","commit_stats":{"total_commits":75,"total_committers":6,"mean_commits":12.5,"dds":"0.41333333333333333","last_synced_commit":"cebf2aa05a41c1c50c76b098c45ac8e57f39c7d2"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wheatjs%2Fvite-plugin-vue-type-imports","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wheatjs%2Fvite-plugin-vue-type-imports/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wheatjs%2Fvite-plugin-vue-type-imports/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wheatjs%2Fvite-plugin-vue-type-imports/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wheatjs","download_url":"https://codeload.github.com/wheatjs/vite-plugin-vue-type-imports/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174417,"owners_count":20896078,"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":[],"created_at":"2024-07-31T09:00:31.680Z","updated_at":"2025-04-04T12:07:21.603Z","avatar_url":"https://github.com/wheatjs.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003ch2 align=\"center\"\u003evite-plugin-vue-type-imports\u003c/h2\u003e\n\n\u003cp align=\"center\"\u003e\n  Enables you to import types and use them in your \u003ccode\u003edefineProps\u003c/code\u003e and \u003ccode\u003edefineEmits\u003c/code\u003e. Supports both Vue 2 and Vue 3.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://www.npmjs.com/package/vite-plugin-vue-type-imports\" target=\"__blank\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/vite-plugin-vue-type-imports?color=a356fe\u0026label=Version\" alt=\"NPM version\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003e ⚠️ This Plugin is still in Development and there may be bugs. Use at your own risk.\n\n## Install\n```bash\n# Install Plugin\nnpm i -D vite-plugin-vue-type-imports\n```\n\n```ts\n// vite.config.ts\n\nimport { defineConfig } from 'vite'\nimport Vue from '@vitejs/plugin-vue'\nimport VueTypeImports from 'vite-plugin-vue-type-imports'\n\nexport default defineConfig({\n  plugins: [\n    Vue(), \n    VueTypeImports(),\n  ],\n})\n```\n\n### Nuxt\n```ts\n// nuxt.config.ts\n\nexport default {\n  buildModules: [\n    'vite-plugin-vue-type-imports/nuxt',\n  ]\n}\n```\n\n## Usage\n\n```ts\n// types.ts\n\nexport interface User {\n  username: string\n  password: string\n  avatar?: string\n}\n```\n\n```html\n\u003cscript setup lang=\"ts\"\u003e\nimport type { User } from '~/types'\n\ndefineProps\u003cUser\u003e()\n\u003c/script\u003e\n\n\u003ctemplate\u003e...\u003c/template\u003e\n```\n\n## Known limitations\n- Namespace imports like `import * as Foo from 'foo'` are not supported.\n- [These types](https://www.typescriptlang.org/docs/handbook/2/types-from-types.html) are not supported.\n- The plugin currently only scans the content of `\u003cscript setup\u003e`. Types defined in `\u003cscript\u003e` will be ignored.\n\n## Notes\n- `Enum` types will be converted to Union Types (e.g. `type [name] = number | string`) , since Vue can't handle them right now.\n- The plugin may be slow because it needs to read files and traverse the AST (using @babel/parser).\n\n## Caveats\n- **Do not reference the types themselves implicitly, it will cause infinite loop**.\nVue will also get wrong type definition even if you disable this plugin.\n\nIllegal code:\n```ts\nexport type Bar = Foo\nexport interface Foo {\n  foo: Bar\n}\n```\n\nAlternatively, you can reference the types themselves in their own definitions\n\nAcceptable code:\n```ts\nexport type Bar = string\n\nexport interface Foo {\n  foo: Foo\n  bar: Foo | Bar\n}\n```\n\n- Ending the type name with something like `_1` and `_2` is not recommended, because it may **conflict** with the plugin's transformation result\n\nThese types may cause conflicts:\n```ts\ntype Foo_1 = string\ntype Bar_2 = number\n```\n\n## License\n\n[MIT License](https://github.com/jacobclevenger/vite-plugin-vue-gql/blob/main/LICENSE) © 2021-PRESENT [Jacob Clevenger](https://github.com/jacobclevenger)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwheatjs%2Fvite-plugin-vue-type-imports","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwheatjs%2Fvite-plugin-vue-type-imports","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwheatjs%2Fvite-plugin-vue-type-imports/lists"}