Skip to content

Commit

Permalink
fix(bridge): ensure vue ts alias points to original vue (nuxt#1924)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Nov 15, 2021
1 parent 36f3691 commit 4b367a1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 8 additions & 1 deletion docs/content/1.getting-started/3.bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
11 changes: 11 additions & 0 deletions packages/bridge/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand Down

0 comments on commit 4b367a1

Please sign in to comment.