[Vuejs]-Using typescript with vue 3 without using the vue cli

0👍

To use typescript in Vue Options API you should wrap your Options components into defineComponent

export default defineComponent({
  data: () => ({...}),
  props: ['a', 'b'],
  computed: {...},
  // template: '...'
});


However, that won’t work with templates, if you don’t use tooling to use .vue files (as templates are just strings, while in vue files they are seperate language)

If you want to switch to tooling, check out the latest Vue script setup

(I was rewriting .vue in Options into Script Setup, with some hand-made regex-based converter making half of work)

Maybe some component framework like https://quasar.dev/

Maybe with plugins like unplugin-auto-import (removes need in importing often-used things like ref of computed)

Leave a comment