egoist / vue-compile

Compile the blocks in Vue single-file components to use JS/CSS instead of Babel/Sass/Stylus.
MIT License
159 stars 10 forks source link

Support for types d.ts #146

Open mesqueeb opened 4 years ago

mesqueeb commented 4 years ago

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 ?

mesqueeb commented 4 years ago

@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.

egoist commented 3 years ago

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

mesqueeb commented 3 years ago

@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:

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

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

egoist commented 3 years ago

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

mesqueeb commented 3 years ago

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

egoist commented 3 years ago

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

egoist commented 3 years ago

So I made one here: https://github.com/egoist/vue-dts-gen