Skip to content

Instantly share code, notes, and snippets.

@gkweb
Last active March 9, 2022 12:23
Show Gist options
  • Save gkweb/1af824878b5b2c8dd055debde4d8febf to your computer and use it in GitHub Desktop.
Save gkweb/1af824878b5b2c8dd055debde4d8febf to your computer and use it in GitHub Desktop.
Nuxt 2 and Typescript in 2022

NuxtJS 2 and Vue typescript

Props:

Import PropType from @vue/runtime-core and NOT @nuxtjs/composition-api

The legacy composition-api library is outdated and no longer maintained.

import type { PropType } from '@vue/runtime-core'

Volar

See setup here: https://github.com/johnsoncodehk/volar/tree/master/extensions/vscode-vue-language-features

Quickly it's just adding this to tsconfig.json

"vueCompilerOptions": {
    "experimentalCompatMode": 2
  },

Tsconfig

I've found that disabling the below items has been best to work with. strictNullChecks is overkill for a legacy project.

"noUnusedLocals": false,
"strictNullChecks": false

Paths needs to be added to infer webpack aliasing. example:

"paths": {
  "@/types/*": ["./types/*"],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment