egoist / vue-compile

Compile the blocks in Vue single-file components to use JS/CSS instead of Babel/Sass/Stylus.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for types d.ts

mesqueeb opened this issue · comments

Hey Egoist,
Thanks for this awesome library and the suggestion.

If components could be typed so there's better auto completion in VSCode that's would be really awesome !!

Do you have any ideas how to achieve this ?

@egoist

For Vue 2, a framework like Quasar exposed types like these when importing components:

export interface QInput extends Vue {
    /**
     * Used to specify the name of the control; Useful if dealing with forms; If not specified, it takes the value of 'for' prop, if it exists
     */
    name? : string
    /**
     * Custom mask or one of the predefined mask names
     */
    mask? : string
   // etc...

I don't think it might be worth trying to create this feature for Vue 2. I'd say in favour of spending time more wisely only focus on Vue 3.

It might actually be a good idea to just publish <script lang="ts"> as is now since transpiling TypeScript is fast (Vite).

@egoist is it possible to use lang="ts" even if your components are used in non-ts Vue 3 projects?


For anyone coming here, if you're looking to add IntelliSense to your Vue components:

  • auto completion & suggestions for props
  • documentation snippets when hovering over props

Then you can use the package vue-intellisense for that:

https://github.com/cycraft/vue-intellisense

is it possible to use lang="ts" even if your components are used in non-ts Vue 3 projects?

Yes for Vite.

I also recommend this vscode extension for vue 3 projects https://github.com/johnsoncodehk/volar

@egoist thanks for telling me this tool! Is it to be used alongside vetur or meant to replace vetur?

It replaces Vetur, in fact there would be conflicts if you have both of them enabled.