-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
configurationProject setup and configuration filesProject setup and configuration filesenhancementNew feature or requestNew feature or request
Milestone
Description
feat(typescript): add TypeScript support
| β±οΈ Estimate | π Priority | π Size | π Start | π End |
|---|---|---|---|---|
| 4h | P3 | M | 24-01-2026 | 24-01-2026 |
πΈ Screenshots
| Current | Expected |
|---|---|
| N/A β This change has no visual impact. | N/A β This change has no visual impact. |
π Summary
- Add
TypeScriptsupport (typescript,vue-tsc,@vue/tsconfig) - Configure
TypeScriptwithvue@3andESLint(@typescript-eslint/parser,@typescript-eslint/eslint-plugin) - Add type declarations (
env.d.ts,shims-vue.d.ts) and optionally migrate components
π‘ Why this change?
JavaScriptlacks static type checking, causing runtime errors that could be caught earlier- Without type annotations, IDE support is limited to inference
- The
vue@3was designed withTypeScriptas a first-class citizen - Industry standard for modern frontend projects
β Benefits
- Catch type errors at compile time before they reach production
- Full IDE autocompletion, IntelliSense and refactoring support
- Self-documenting code with explicit type contracts
- Safer and easier refactoring across the codebase
- Access to
vue@3typed APIs (defineProps,defineEmits,Ref<T>)
π Steps
Phase 1: Install TypeScript dependencies
- Install
TypeScriptand VueTypeScriptsupport asdevDependencies:
npm install -D typescript vue-tsc @vue/tsconfig- Install
TypeScriptandESLintsupport asdevDependencies:
npm install -D @typescript-eslint/parser @typescript-eslint/eslint-pluginPhase 2: Create TypeScript configuration
- Create
tsconfig.json:
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"jsx": "preserve",
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"skipLibCheck": true,
"noEmit": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"],
"~/*": ["src/*"]
}
},
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
"exclude": ["node_modules", "dist"]
}- Update or remove
jsconfig.json(tsconfig.json replaces it)
Phase 3: Update Vite configuration
- Update
vite.config.jstovite.config.ts(optional) - Ensure Vite handles
TypeScriptfiles
Phase 4: Add type checking script
- Add type check script to
package.json:
"scripts": {
"ts:check": "vue-tsc --noEmit",
"build": "vue-tsc --noEmit && vite build"
}Phase 5: Update ESLint configuration
- Add
TypeScriptsupport toeslint.config.js:
import tseslint from "typescript-eslint";
export default tseslint.config(
// ... existing config
...tseslint.configs.recommended,
{
files: ["**/*.ts", "**/*.tsx", "**/*.vue"],
languageOptions: {
parserOptions: {
projectService: true,
},
},
},
);Phase 6: Add type declarations
- Create
src/env.d.tsfor environment variables:
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_GOOGLE_MAPS_API_KEY: string;
// add more env variables as needed
}
interface ImportMeta {
readonly env: ImportMetaEnv;
}- Create
src/shims-vue.d.tsif needed:
declare module "*.vue" {
import type { DefineComponent } from "vue";
const component: DefineComponent<{}, {}, any>;
export default component;
}Phase 7: Migrate files to TypeScript (optional)
- Rename
.jsfiles to.tsgradually - Add type annotations to Vue components:
<script setup lang="ts">
import { ref } from "vue";
const count = ref<number>(0);
</script>- Add types to props, emits, and composables
π§ͺ Tests
- Verify
TypeScriptchecking runs without errors:
npm run ts:check- Confirm build runs successfully:
npm run build- Check that the IDE shows autocompletion and type hints for
TypeScriptfiles - Check for runtime errors from type issues
- Confirm
ESLintworks withTypeScriptfiles
π Notes
- This issue requires completing
vue@3migration first - Can start with just configuration and migrate files gradually
<script setup lang="ts">is the recommended syntax forvue@3- Consider using
definePropsanddefineEmitswith type annotations
π References
Files to create
tsconfig.jsonsrc/env.d.tssrc/shims-vue.d.ts
Files to modify
vite.config.jseslint.config.jspackage.json
Files to remove
jsconfig.json
Documentation
- https://vuejs.org/guide/typescript/overview.html
- https://vitejs.dev/guide/features.html#typescript
- https://typescript-eslint.io/
Related Issues
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
configurationProject setup and configuration filesProject setup and configuration filesenhancementNew feature or requestNew feature or request