Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<template> Shows errors on variables despite being defined in <script> with Volar & Typescript #215

Closed
Luffyyy opened this issue Oct 16, 2021 · 7 comments · Fixed by nuxt/framework#1924
Assignees
Labels
bridge bug Something isn't working dx

Comments

@Luffyyy
Copy link

Luffyyy commented Oct 16, 2021

Environment


  • Operating System: Windows_NT
  • Node Version: v16.6.2
  • Nuxt Version: 2.16.0-27226092.034b9901
  • Package Manager: Yarn
  • Bundler: Webpack
  • User Config: head, css, plugins, components, buildModules, modules, build
  • Runtime Modules: -
  • Build Modules: @nuxt/bridge@3.0.0-27238235.a1bcc53

Describe the bug

image

Basically the image, I installed a clean Nuxt 2, converted it to bridge, made a tsconfig as described here #236, added the following (from what I found regarding using Vue 2 with Volar):

    "compilerOptions": {
      "types": [
        "unplugin-vue2-script-setup/types"
      ]
    },
    "vueCompilerOptions": {
      "experimentalCompatMode": 2
    },

Tried installing @vue/runtime-dom and unplugin-vue2-script-setup, but nothing. The error is still there.
I tried defining them via options API too, seems to be broken there too.

I might have done something wrong, I mostly use JS but wanted to try TS at some point. Could also be a Volar issue, but I'm unsure. It works fine with Nuxt 3 or just Vue 3.

Reproduction

https://github.com/Luffyyy/nuxt2-bridge-issue

Additional context

No response

Logs

No response

@Luffyyy Luffyyy added bridge bug Something isn't working labels Oct 16, 2021
@danielroe danielroe added dx upstream and removed bug Something isn't working labels Oct 18, 2021
@danielroe
Copy link
Member

danielroe commented Oct 18, 2021

I don't believe this is a Nuxt Bridge issue; rather, it's a tooling issue (as <script setup> doesn't have mainstream support for Vue 2).

Consider raising an issue with Volar.

@sduduzog
Copy link

sduduzog commented Oct 18, 2021

I've faced these issue too, I'm yet to setup a reproduction repo, given that I don't find a solution to this soon... It also happens even when just using the composition api for me with the properties being returned from the setup function.

I don't believe this is a Nuxt Bridge issue; rather, it's a tooling issue (as <script setup> doesn't have mainstream support for Vue 2).

Consider raising an issue with Volar.

It's worth noting that I have volar setup and working perfectly (had to also install @vue/runtime-dom) with Nuxt 2 without the bridge

@pi0
Copy link
Member

pi0 commented Oct 22, 2021

Opening an issue on volar would probably be best.

/cc @johnsoncodehk Please let us know if you expect any special setup to hint volar working with nuxt 2 projects. We can add it to auto-generated types or bridge starter or docs as you wish :)

@pi0 pi0 closed this as completed Oct 22, 2021
@johnsoncodehk
Copy link

The problem is that .nuxt/tsconfig.json cause to @vue/composition-api types broken.

螢幕截圖 2021-10-23 上午5 49 27

@danielroe danielroe reopened this Oct 22, 2021
@danielroe danielroe added bug Something isn't working and removed upstream labels Oct 25, 2021
@danielroe
Copy link
Member

@johnsoncodehk Even without the path aliases in tsconfig.json, the same issue shows up... Do you have any more guidance for us?

@johnsoncodehk
Copy link

@danielroe After I reinstalled the repro case and built it, there is no problem, because ./.nuxt/tsconfig.json is gone. What can I do to reproduce your problem?

螢幕截圖 2021-11-03 下午12 50 47

@pleclech
Copy link

Hi,
Having the same problem, it seems that the line

  "vue": [
   "node_modules/@nuxt/bridge/dist/runtime/vue2-bridge"
 ],

in ./.nuxt/tsconfig.json break Volar type checking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bridge bug Something isn't working dx
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants