fix(bridge): ensure `vue` ts alias points to original vue (#1924)

This commit is contained in:
Daniel Roe 2021-11-15 15:58:43 +00:00 committed by GitHub
parent 36f3691bf8
commit 4b367a1959
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -127,10 +127,17 @@ If you are using TypeScript, you can edit your `tsconfig.json` to benefit from a
+ "extends": "./.nuxt/tsconfig.json",
"compilerOptions": {
...
}
},
+ "vueCompilerOptions": {
+ "experimentalCompatMode": 2,
+ }
}
```
::alert
You may also need to add `@vue/runtime-dom` as a devDependency if you are struggling to get template type inference working with [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar).
::
## Migrate Composition API
If you were previously using `@vue/composition-api` or `@nuxtjs/composition-api`, please read the [composition api migration guide](/getting-started/bridge-composition-api).

View File

@ -50,6 +50,17 @@ export function setupAppBridge (_options: any) {
nuxt.options.alias[alias] = nuxt.options.alias['vue2-bridge']
}
// Ensure TS still recognises vue imports
nuxt.hook('prepare:types', ({ tsConfig }) => {
tsConfig.compilerOptions.paths.vue2 = ['vue']
delete tsConfig.compilerOptions.paths.vue
// @ts-ignore
tsConfig.vueCompilerOptions = {
experimentalCompatMode: 2
}
})
// Deprecate various Nuxt options
if (nuxt.options.globalName !== 'nuxt') {
throw new Error('Custom global name is not supported by @nuxt/bridge.')