create-nuxt-app
create-nuxt-app copied to clipboard
Typescript: project should include a definition file for files with .vue extension
Projects using typescript should include a definition file: vue-shim.d.ts
declare module "*.vue" {
import Vue from 'vue'
export default Vue
}
this allows importing .vue modules inside .ts files ( for unit tests for instance)
Let’s see what @kevinmarrec thinks about this :)
It's mentionned in documentation : https://typescript.nuxtjs.org/guide/setup.html#configuration
You will also need to provide types for Vue files by adding the following type declaration ...
Documentation ... who has time to read them ? 😁😜
More seriously, why not add that file directly when typescript is selected ?
Oh yeah nvm it should be indeed added by CNA :)
Adding it to the repo will indeed be helpful as now doing it with documentation gives error:
Parsing error: Imports within a `declare module` body must always be `import type` or `import typeof`
...and trying to modify piece from docs to be:
declare module '*.vue' {
import type Vue from 'vue';
export default Vue;
}
...gives following error:
Parsing error: Only declares and type imports are allowed inside declare module
@Reeywhaar
This PR adds it : https://github.com/nuxt/create-nuxt-app/pull/449
And about your error, I never had this one, I think you have a mistake in your configuration, please open a new issue on TypeScript repo with reproduction so I can find a fix for you.
@Reeywhaar I think it's babel error, you maybe didn't see Warning in : https://typescript.nuxtjs.org/guide/lint.html#configuration