Master Vue TypeScript - Type-safe Components, Generics, Type Inference, Advanced Patterns
Teaches TypeScript integration with Vue 3 including typed components, generics, and advanced type patterns.
/plugin marketplace add pluginagentmarketplace/custom-plugin-vue/plugin install vue-assistant@pluginagentmarketplace-vueThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/config.yamlassets/schema.jsonreferences/GUIDE.mdreferences/PATTERNS.mdscripts/validate.pyProduction-grade skill for mastering TypeScript integration with Vue 3 applications.
Single Responsibility: Teach TypeScript integration with Vue including typed components, generics, type inference, and advanced type patterns.
interface VueTypeScriptParams {
topic: 'config' | 'components' | 'generics' | 'stores' | 'inference' | 'all';
level: 'beginner' | 'intermediate' | 'advanced';
context?: {
strict_mode?: boolean;
existing_js?: boolean;
};
}
Prerequisites: vue-fundamentals, TypeScript basics
Duration: 1-2 hours
Outcome: Configure TypeScript for Vue
| Topic | File | Content |
|---|---|---|
| tsconfig | tsconfig.json | Vue-specific config |
| Volar | Extension | IDE support |
| env.d.ts | Type declarations | Vite/Vue types |
| vue-tsc | Build check | Type validation |
tsconfig.json:
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"jsx": "preserve",
"jsxImportSource": "vue"
},
"include": ["src/**/*.ts", "src/**/*.vue"]
}
Prerequisites: Module 1
Duration: 3-4 hours
Outcome: Write type-safe components
| Feature | Syntax | Exercise |
|---|---|---|
| Props | defineProps<Props>() | Typed props |
| Emits | defineEmits<Emits>() | Typed events |
| Defaults | withDefaults() | Default values |
| Expose | defineExpose() | Public API |
| Slots | defineSlots() | Typed slots |
Typed Component:
<script setup lang="ts">
interface Props {
title: string
count?: number
items: Item[]
}
interface Emits {
(e: 'update', value: string): void
(e: 'select', item: Item): void
}
const props = withDefaults(defineProps<Props>(), {
count: 0
})
const emit = defineEmits<Emits>()
</script>
Prerequisites: Module 2
Duration: 3 hours
Outcome: Build reusable generic components
Generic Component:
<script setup lang="ts" generic="T extends { id: string | number }">
interface Props {
items: T[]
selected?: T
}
interface Emits {
(e: 'select', item: T): void
}
const props = defineProps<Props>()
const emit = defineEmits<Emits>()
</script>
<template>
<ul>
<li v-for="item in items" :key="item.id" @click="emit('select', item)">
<slot :item="item" />
</li>
</ul>
</template>
Prerequisites: Module 3
Duration: 3-4 hours
Outcome: Type-safe reusable logic
| Pattern | Typing Technique | Exercise |
|---|---|---|
| Composable return | Interface | useFetch<T> |
| Store state | Typed refs | User store |
| Getters | Computed types | Derived state |
| Actions | Async types | API actions |
Typed Composable:
interface UseFetchReturn<T> {
data: Ref<T | null>
error: Ref<Error | null>
loading: Ref<boolean>
execute: () => Promise<void>
}
export function useFetch<T>(url: MaybeRefOrGetter<string>): UseFetchReturn<T> {
const data = ref<T | null>(null) as Ref<T | null>
// ...
return { data, error, loading, execute }
}
Prerequisites: Modules 1-4
Duration: 3-4 hours
Outcome: Expert-level Vue typing
| Pattern | Use Case | Example |
|---|---|---|
| Utility types | Props extraction | ExtractProps<T> |
| Module augmentation | Route meta | RouteMeta interface |
| Conditional types | API responses | ResponseType<T> |
| Template refs | Component refs | ComponentRef<T> |
Utility Types:
// Extract props from component
type ExtractProps<T> = T extends new () => { $props: infer P } ? P : never
// Deep partial
type DeepPartial<T> = {
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]
}
// Component ref type
type ComponentRef<T> = T extends new () => infer R ? R : never
const buttonRef = ref<ComponentRef<typeof Button> | null>(null)
const skillConfig = {
maxAttempts: 3,
backoffMs: [1000, 2000, 4000],
onFailure: 'simplify_type_definition'
}
tracking:
- event: type_error_fixed
data: [error_code, file]
- event: pattern_learned
data: [pattern_name, complexity]
- event: skill_completed
data: [strict_mode, any_count]
| Issue | Cause | Solution |
|---|---|---|
| defineProps not typed | Missing generic | Add <Props> |
| Cannot find module | Missing declaration | Add env.d.ts |
| Generic not working | Vue < 3.3 | Upgrade Vue |
| Type not inferred | Complex type | Explicit annotation |
import { describe, it, expect } from 'vitest'
import { mount } from '@vue/test-utils'
import GenericList from './GenericList.vue'
interface User {
id: number
name: string
}
describe('GenericList', () => {
it('renders items with correct types', () => {
const users: User[] = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' }
]
const wrapper = mount(GenericList<User>, {
props: { items: users },
slots: {
default: ({ item }: { item: User }) => item.name
}
})
expect(wrapper.text()).toContain('Alice')
expect(wrapper.text()).toContain('Bob')
})
it('emits typed select event', async () => {
const users: User[] = [{ id: 1, name: 'Alice' }]
const wrapper = mount(GenericList<User>, {
props: { items: users }
})
await wrapper.find('li').trigger('click')
const emitted = wrapper.emitted('select')
expect(emitted?.[0][0]).toEqual({ id: 1, name: 'Alice' })
})
})
Skill("vue-typescript")
vue-fundamentals - Prerequisitevue-composition-api - For typed composablesvue-testing - Type-safe testingThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.