VSCode extension to Konvert your Vue props from objects to TS generic syntax.
Convert Vue defineProps() object-style definitions into type-safe, destructured TypeScript automatically in VS Code.
[!WARNING]
This extension is currently in beta. Some features may not work perfectly. For example:
- Callback props may not be correctly inferred
- Extremely dynamic or computed prop definitions
- Certain nested default values or unusual object syntax
Please report any issues on the GitHub repository.
defineProps to TypeScript generic + destructuring syntaxprops.propName usages with destructured variablesPropType<T> for arrays, objects, or custom types<script lang="ts">)undefinedBefore:undefined
const props = defineProps({
title: {
type: String,
default: 'Untitled',
},
isPublished: {
type: Boolean,
required: true,
},
tags: {
type: Array as PropType<string[]>,
default: () => ['vue', 'typescript'],
},
metadata: {
type: Object as PropType<{ author: string; date: string }>,
default: () => ({ author: 'Unknown', date: new Date().toISOString() }),
},
maxItems: {
type: Number,
default: 10,
},
callback: {
type: Function as PropType<() => void>,
},
})
undefinedAfter conversion:undefined
const {
title = 'Untitled',
isPublished,
tags = (['vue', 'typescript']),
metadata = ({ author: 'Unknown', date: new Date().toISOString() }),
maxItems = 10,
} = defineProps<{
title?: string
isPublished: boolean
tags?: string[]
metadata?: { author: string; date: string }
maxItems?: number
}>()
Ctrl+Shift+X / Cmd+Shift+X)git clone https://github.com/yourusername/vue-prop-konverter.git
cd vue-prop-konverter
pnpm install
pnpm run build
Then press F5 in VS Code to open a Development Extension Host with the extension loaded.
.vue file with <script setup lang="ts">defineProps() object-style declarationCtrl + . / Cmd + .Replace defineProps() with type-safe variant and update usage<script setup lang="ts">No additional settings required — works out of the box.
git checkout -b feature/my-feature)pnpm lint and pnpm build