Skip to content

non-setup script is using the setup script variables declarations in dev but not in runtime #5604

@xianshenglu

Description

@xianshenglu

Vue - Official extension or vue-tsc version

3.5.18

VSCode version

N.A.

Vue version

3.5.18

TypeScript version

5.9.2

System Info

package.json dependencies

{
  "imports": {
    "vue": "https://cdn.jsdelivr.net/npm/@vue/[email protected]/dist/runtime-dom.esm-browser.js",
    "vue/server-renderer": "https://cdn.jsdelivr.net/npm/@vue/[email protected]/dist/server-renderer.esm-browser.js",
    "vue-router": "https://unpkg.com/[email protected]/dist/vue-router.esm-browser.js",
    "@vue/devtools-api": "https://unpkg.com/@vue/[email protected]/lib/esm/index.js"
  },
  "scopes": {}
}

Steps to reproduce

  1. open the demo
  2. hover on the counter variable inside the beforeRouteEnter function in HomeView.vue

What is expected?

counter is undefined

What is actually happening?

online-editor and VS Code:
Image

runtime:

Image

Link to minimal reproduction

https://play.vuejs.org/#eNp9VWtv2zYU/SsX6gfLmC05TlcMnpNmGwJ0A/ZAO+zLNAyydW2rlUiNpBwHhv/7Dkk93bQJDEv3ec69h/Q5KNNcRB91sAryspLK0Jm2ilPDP1QVXWinZEmTY82TRDQBStaGVeOJYv/au21e60urKvK5ieiqhvhME0EU1ZpDn+7fS1kLE05eIW0yDWZBkw5sa8NlVSD/3pYiWlvYeCb8rd+7En/l/ESxs63jxr2OuzyU861eJPsrl1I9v8u1wdesMfq6wyHMO7Id3XeyZNe65dwaGuLtVDbIHMV1ln5CUuhmvJru6G9L5UxVag4rmsQTwJIoJliYVd/2MhuHpbbsOLbvbYP/uWql0GrINzzbggc/itVL8wmnrqcHiscLtpcIPjmiGe/SumhrY+rDeVxtkoASGweEY1rUvKLzuTFcLqPl2fprvVV5ZYiKVOzvksDoJIDjqq0Dv+GdVJ7Oo60WTp3ZthNaFhwVch9OmlaTWfMwpTimgzwCjhRkDtyhe5Y1PeVFQZqZckO5phLazMWejBxFbriQTzPa1AgSpGDMS5eSSdZiYiwMUHPsPJ8RN82mrq4ItstqW9zRzfdX6ZjySE12zMOKCOr1Dl1gLtnLZ/tMOJNucLPu6Ysn4EpEXXwIPQx8A5f1tD7NqdoerPgaRF54ezbh1K8REgN6hTna3Oi/mtVz1KS9fUsTgMA0nRZBM/SePtefdsWQ0JbDM7l8aKztfCErXL8PPIwXMlLp+rC87wa8jvHmrEWKdTeX0AdXc0XrXIAMHeelzLiIjMpLrNJ3TALI5lSw2JsDjMuF26+9rtpK4/vK72QOqeHOkgJbddSSxgF5gI1vnwT9bqw5CQ7GVHoVx7WoPu0jzDjuIx5eR7fRIs5wnAfWiHU53yj5pN0lmQRusrb2A4LijI9GykLP0yr/UovPAh/eRG+im7jINzGqx7nI+ORqt4MHTaMhiF2+vyJpZZEXrH6vTA7BjMimBY7ZL85mVM0d0O2Bt59esH/UJw/5D8Vgd+QBOZMqaM67Hz/8xic8d05ssS4Q/RXne8aVUluMPuzHWmSAPYhzaH92O8OV8ad+PBkWuiVlgfZCdov86SvUe7i30evBFLV5LlhHW21/3UR6nEFruIL8fShVxmpFy+pEAJtn9GqxWOAWIQSpfS7mG2mMLFd0s6hOzl6lWQawnQVdEoGydE8pfYOPK9xkF7zDz8ww8rAcdu7L9wC22+0AwIoW+F82FUDnX1zDdkQgcxt9G918F1z+ByMX+mo=

Any additional comments?

This is the simplest case. The real-world case I met is

Image

It throws an error 'counter' is declared but its value is never read for the import of counter. If I delete the import the app will fail

Metadata

Metadata

Assignees

No one assigned

    Labels

    good reproduction ✨This issue provides a good reproduction, we will be able to investigate it first🔩 p2-edge-case

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions