Skip to content

Regression in slot typings #5206

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

Closed
darkbasic opened this issue Feb 23, 2025 · 11 comments
Closed

Regression in slot typings #5206

darkbasic opened this issue Feb 23, 2025 · 11 comments
Labels
question Further information is requested

Comments

@darkbasic
Copy link

Vue - Official extension or vue-tsc version

2.2.4

VSCode version

1.97.2

Vue version

3.5.13

TypeScript version

5.6.3

System Info

System:
    OS: Linux 6.13 Arch Linux
    CPU: (16) x64 AMD Ryzen 9 PRO 7940HS w/ Radeon 780M Graphics
    Memory: 32.16 GB / 54.70 GB
    Container: Yes
    Shell: 5.2.37 - /bin/bash
  Binaries:
    Node: 22.14.0 - /run/user/1000/fnm_multishells/5326_1740124809918/bin/node
    Yarn: 4.6.0 - /run/user/1000/fnm_multishells/5326_1740124809918/bin/yarn
    npm: 10.9.2 - /run/user/1000/fnm_multishells/5326_1740124809918/bin/npm
    Watchman: 20240414.112832.0 - /usr/bin/watchman
  Browsers:
    Chromium: 133.0.6943.126

package.json dependencies

Steps to reproduce

Playground:

TabRend errors out at line 87 if you upgrade vue-tsc to 2.2.4 which has just been released.

What is expected?

The slot typings should be valid.

What is actually happening?

src/components/VTable/TabRend.vue:86:12 - error TS2345: Argument of type '{ value: T["key"] extends keyof U ? U[T["key"]] : T["value"] extends keyof U ? U[T["value"]] : T["value"] extends (...args: unknown[]) => unknown ? ReturnType<...> : never; }' is not assignable to parameter of type 'NonNullable<(Readonly<__VLS_Slots> & __VLS_Slots)[T["key"]]> extends (props: infer P) => any ? P : {}'.

86           <slot :name="slotName(tuple, item, index)" :value="getValue(tuple, item, index)">
              ~~~~


Found 1 error.

Link to minimal reproduction

https://play.vuejs.org/#eNrtWM1u20YQfpUJC0QyIEpx2l5YSk4apEAL1DEcuT2IOlDkyqFD7RJc0rGg6t07sz/kSpZk2Q0cFMhFJ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Of2oNWfHkvC8W8reZUlzUohqXaEHZ2Oh12vGWZkleKLRuWq65iXDYk1D294wNt353QHzlUeLzh5Olmcd4t/H6Lceo24GPuai+jMuvmUKxnbg0qC8sOjirlyU2MKbRmLWXstwCOhGSYsxHj2QoUZ0O0F7xI/Oz1aGWlVOepwEYX+0oJlszWueqC6Tyd/MY9eejcU7miCNEycBbJFofO5Jioa2VL7dE3sx1LP15UtYrfuV+KhS3E9wNmxbR33DIXQmYnbDkgqsk1P8OFEBpGyecXZB6QyVSbX9UOErkNXmEyD41CBG3ZNWhKoTm5FbqCjTg6uRYWugkUim1vWMhax+zxtTuoixurs2up6KDAPDhwDOMTVuhx1NzqcbCVBik2z6oo/u0F3YUQE4SFXP/B+EaXo7kq/uheoUchu18hKzqm/M1nmXbBhioAxOtkXhzJXCWE8IRBOznj2HlveKJn6zRn7C/w409zOsSueuhlUKt/5clDjFuwluUgv8CsmwYu9OqJ0pF2ixR8vIoRnIHWf5NAuo8ZZETdbtMmoWUseFQeMDPjrehdVMpEvX1dY5gqkHN8ot83lh3brZ8OYrhaRWqDe4z9GOhp3AZ2UpynY7N1x0VyGgj3NUZi+uzqauJWubTKrUIp+t/N18GwYUtof4N2AmQMkJFw4XeR0WInQ/iE2jhyN6parRaQAbH4KTV1O7EjbqDkfu6DM3zVWIX6ztJ+197cfChUYeCdV/hen0MEynj4XJ0fcwTNvaj4UJjTwzTK8Pw/T6sTA5+h6GaVv7sTChkWNgctrFZtdrGh0+m2a9+WW+/hcK2HTx

Any additional comments?

https://stackoverflow.com/questions/79460089/tuple-type-inference-in-vue-js-named-slots-with-typescript/

@KazariEX
Copy link
Member

According to my investigation, this issue also exists in v2.2.2.

Image

@KazariEX
Copy link
Member

There should be no problem with this function itself.

function __VLS_asFunctionalSlot<S>(slot: S): (props: NonNullable<S> extends (props: infer P) => any ? P : {}) => void;

@KazariEX KazariEX added question Further information is requested and removed pending triage labels Feb 23, 2025
@KazariEX
Copy link
Member

Image

@KazariEX KazariEX closed this as not planned Won't fix, can't repro, duplicate, stale Feb 23, 2025
@darkbasic
Copy link
Author

According to my investigation, this issue also exists in v2.2.2.

@KazariEX are you sure?

[niko@arch-phoenix portal-ui]$ yarn vue-tsc --build --force
[niko@arch-phoenix portal-ui]$ git diff package.json
diff --git a/package.json b/package.json
index e032aea..bad93f4 100644
--- a/package.json
+++ b/package.json
@@ -129,7 +129,7 @@
     "vite-plugin-vuetify": "^2.1.0",
     "vitest": "^3.0.6",
     "vue-router": "^4.5.0",
-    "vue-tsc": "^2.2.4"
+    "vue-tsc": "2.2.2"
   },
   "nyc": {
     "extension": [
[niko@arch-phoenix portal-ui]$ git checkout package.json; yarn; yarn vue-tsc --build --force
Updated 1 path from the index
➤ YN0000: · Yarn 4.6.0
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + vue-tsc@npm:2.2.4, @vue/language-core@npm:2.2.4
➤ YN0085: │ - @vue/language-core@npm:2.2.2, vue-tsc@npm:2.2.2
➤ YN0000: └ Completed in 0s 410ms
➤ YN0000: ┌ Post-resolution validation
➤ YN0002: │ idf-portal-ui@workspace:. doesn't provide @babel/core (pa343b), requested by @cypress/code-coverage.
➤ YN0002: │ idf-portal-ui@workspace:. doesn't provide @babel/preset-env (p3beda), requested by @cypress/code-coverage.
➤ YN0002: │ idf-portal-ui@workspace:. doesn't provide @typescript-eslint/parser (p46ad0), requested by @typescript-eslint/eslint-plugin and other dependencies.
➤ YN0002: │ idf-portal-ui@workspace:. doesn't provide babel-loader (p572ea), requested by @cypress/code-coverage.
➤ YN0002: │ idf-portal-ui@workspace:. doesn't provide postcss (p363c7), requested by autoprefixer.
➤ YN0002: │ idf-portal-ui@workspace:. doesn't provide webpack (p55d68), requested by @cypress/code-coverage.
➤ YN0086: │ Some peer dependencies are incorrectly met by your project; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code.
➤ YN0086: │ Some peer dependencies are incorrectly met by dependencies; run yarn explain peer-requirements for details.
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 0s 725ms
➤ YN0000: ┌ Link step
➤ YN0008: │ idf-portal-ui@workspace:. must be rebuilt because its dependency tree changed
➤ YN0000: └ Completed in 0s 383ms
➤ YN0000: · Done with warnings in 1s 628ms
src/components/VTable/TabRend.vue:86:12 - error TS2345: Argument of type '{ value: T["key"] extends keyof U ? U[T["key"]] : T["value"] extends keyof U ? U[T["value"]] : T["value"] extends (...args: unknown[]) => unknown ? ReturnType<...> : never; }' is not assignable to parameter of type 'NonNullable<(Readonly<__VLS_Slots> & __VLS_Slots)[T["key"]]> extends (props: infer P) => any ? P : {}'.

86           <slot :name="slotName(tuple, item, index)" :value="getValue(tuple, item, index)">
              ~~~~


Found 1 error.

@KazariEX
Copy link
Member

KazariEX commented Feb 23, 2025

Sorry, but this is because the errors in v2.2.2 were not correctly mapped back into the code.

This is the virtual code in v2.2.2:

Image

@KazariEX
Copy link
Member

If the type is correct, you should be able to trigger Go To Definition on :value=.

@darkbasic
Copy link
Author

darkbasic commented Mar 19, 2025

@KazariEX could you please check the same example on 3.0.0-alpha.2? Because it looks like it's fixed now but I'm not 100% sure if it's because the errors are once again not correctly mapped back into the code.

@KazariEX
Copy link
Member

KazariEX commented Mar 19, 2025

No, we did not make any fixes as the error originated from your type definition itself:

<template>
  <tr v-for="(item, j) in items" :key="j">
    <td v-for="(column, index) in tuple" :key="column.key">
        <!-- will trigger error at here -->
        {{ slots[slotName(tuple, item, index)]({ value: getValue(tuple, item, index) }) }}
    </td>
  </tr>
</template>

This is the equivalent code for <slot :name="..." :value="..." />.

The reason why the error is not displayed now is indeed due to incomplete mapping.

@darkbasic
Copy link
Author

The reason why the error is not displayed now is indeed due to incomplete mapping.

@KazariEX is there a regression in 2.2.10 in that regard? Because the error disappeared.

@KazariEX
Copy link
Member

KazariEX commented Apr 23, 2025

2.2.10 only picked a few error fixes from 3.0.0. As I provided the code above, you need to solve the type issue yourself.

@darkbasic
Copy link
Author

@KazariEX I don't get the error in the code above anymore with 2.2.10, so I guess there isn't anything to solve with the latest stable version of the language tools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants