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

v2.0.22 regression on uni-app projects #4501

Closed
ModyQyW opened this issue Jun 25, 2024 · 13 comments
Closed

v2.0.22 regression on uni-app projects #4501

ModyQyW opened this issue Jun 25, 2024 · 13 comments
Labels
bug Something isn't working

Comments

@ModyQyW
Copy link

ModyQyW commented Jun 25, 2024

Vue - Official extension or vue-tsc version

v2.0.22

VSCode version

v1.90.2

Vue version

v3.4.30

TypeScript version

v5.5.2

System Info

System:
    OS: macOS 14.5
    CPU: (10) arm64 Apple M2 Pro
    Memory: 33.42 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.1 - ~/.local/state/fnm_multishells/62229_1719280277494/bin/node
    npm: 10.5.0 - ~/.local/state/fnm_multishells/62229_1719280277494/bin/npm
    pnpm: 9.4.0 - ~/.local/state/fnm_multishells/62229_1719280277494/bin/pnpm
    bun: 1.1.16 - /opt/homebrew/bin/bun
    Watchman: 2024.06.17.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 126.0.6478.115
    Safari: 17.5

Steps to reproduce

  1. Pull the project and install dependencies.
npx degit dcloudio/uni-preset-vue#vite-ts my-vue3-project
cd my-vue3-project
npx taze@latest major -fw
npm install @uni-helper/[email protected] -D
  1. Update tsconfig.json as follow.
{
  "extends": "@vue/tsconfig/tsconfig.json",
  "compilerOptions": {
    "sourceMap": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    },
    "lib": ["esnext", "dom"],
    "types": ["@dcloudio/types", "@uni-helper/uni-app-types"]
  },
  "vueCompilerOptions": {
    "plugins": ["@uni-helper/uni-app-types/volar-plugin"]
  },
  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
}
  1. Reload VSC window.

  2. Check src/pages/index/index.vue and find out the types are lost.

image

Link to minimal reproduction

/

Any additional comments?

I can confirm that v2.0.21 is fine, so that it may be caused by v2.0.22 #4492. If you guys can help me and point out how @uni-helper/uni-app-types should be tweaked, I'd appreciate it. Always thank you very much for the work you do! 🙏

image
@skywalker512
Copy link

skywalker512 commented Jun 26, 2024

I think the deletion here caused this issue. The ts file I used below can solve some problems.

type A = import('@vue/runtime-core').GlobalComponents;

declare module 'vue' {
  interface GlobalComponents extends A {}
}

@zzh948498
Copy link

zzh948498 commented Jun 26, 2024

I think the deletion here caused this issue. I can temporarily solve this problem by configuring it like this.

"vueCompilerOptions": {
    "lib": "@vue/runtime-core",
},

Thank you for your help, but there are still some problems. I will use the following code as an example

<el-button type="success" size="a">Success</el-button>
  1. I can't use ctrl+left click type to enter the type declaration file
  2. The type is not checked, because the size="a" I entered is obviously wrong, and there is no red prompt

@skywalker512
Copy link

@zzh948498

If you are using pnpm, you need to install @vue/runtime-core.

@zzh948498
Copy link

zzh948498 commented Jun 26, 2024

@vue/runtime-core

Sorry I didn't describe it clearly.
The global type is indeed loaded successfully
image
But some features are missing, as I described above

This is the result of my rollback to v2.0.21 :
image

@RayGuo-ergou
Copy link
Contributor

If you are using pnpm, you need to install @vue/runtime-core.

Just want to provide a better solution i found, create a .npmrc then add public-hoist-pattern[]=@vue/runtime-core

Note: If in mono repo, it will only work in the root level.

@so1ve
Copy link
Member

so1ve commented Jun 27, 2024

I think the deletion here caused this issue. The configuration I used below can solve some problems, but the props check failed.

"vueCompilerOptions": {
    "lib": "@vue/runtime-core",
},

Unfortunately, the deletion is intentional since TS 5.5 introduced some internal changes that make the old approach to detect if a module/type exists no longer work in TS 5.5.

@skywalker512
Copy link

skywalker512 commented Jun 27, 2024

But some features are missing, as I described above

@zzh948498 I'm sorry I didn't conduct a complete investigation. I have updated the new solution, and it seems to work fine for me.

type A = import('@vue/runtime-core').GlobalComponents;

declare module 'vue' {
  interface GlobalComponents extends A {}
}

@ModyQyW
Copy link
Author

ModyQyW commented Jul 8, 2024

Does this mean that @uni-helper/uni-app-types should tweak the TS type definitions it provides according to #4503 (comment)? or should I just wait for further tweaks and fixes from Volar?

@a81n9
Copy link

a81n9 commented Jul 18, 2024

If you are using pnpm, you need to install @vue/runtime-core.

Just want to provide a better solution i found, create a .npmrc then add public-hoist-pattern[]=@vue/runtime-core

Note: If in mono repo, it will only work in the root level.

I solved the problem perfectly using this method

.npmrc

public-hoist-pattern[]=@vue/runtime-core

or

shamefully-hoist=true

tsconfig

"vueCompilerOptions": {
    "lib": "@vue/runtime-core",
},

image

@llhxhal
Copy link

llhxhal commented Jul 19, 2024

But some features are missing, as I described above

@zzh948498 I'm sorry I didn't conduct a complete investigation. I have updated the new solution, and it seems to work fine for me.

type A = import('@vue/runtime-core').GlobalComponents;

declare module 'vue' {
  interface GlobalComponents extends A {}
}

I should put these code in which file?

@RayGuo-ergou
Copy link
Contributor

RayGuo-ergou commented Jul 19, 2024

I should put these code in which file?

Wherever, as long as you include in tsconfig.json file

@inoryxun
Copy link

如果您使用pnpm,则需要安装@vue/runtime-core。

只是想为我提供更好的解决方案,创建并.npmrc添加public-hoist-pattern[]=@vue/runtime-core
注意:如果在 mono repo 中,将仅在根级别工作。

我用这个方法完美解决了这个问题

.npmrc

public-hoist-pattern[]=@vue/runtime-core

或者

shamefully-hoist=true

ts配置

"vueCompilerOptions": {
    "lib": "@vue/runtime-core",
},

图像

我使用的这个,但是最后view 的类型是any ,全局组件的变成了unknowm

@ModyQyW
Copy link
Author

ModyQyW commented Aug 6, 2024

For those who are stuck in uni-app types, please check https://github.com/uni-helper/uni-types. Also, check #4501 (comment) and https://github.com/vuejs/language-tools/wiki/Global-Component-Types.

I am closing this issue. Please feel free to open another issue if you face problems and don't forget to provide a minimal reproduction. Thanks a lot to all of you guys. 🙏

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

No branches or pull requests

9 participants