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.2.2] Typecheck breaks on slots in the v-if block #5186

Closed
Xenossolitarius opened this issue Feb 16, 2025 · 7 comments · Fixed by #5189
Closed

[v2.2.2] Typecheck breaks on slots in the v-if block #5186

Xenossolitarius opened this issue Feb 16, 2025 · 7 comments · Fixed by #5189

Comments

@Xenossolitarius
Copy link

Vue - Official extension or vue-tsc version

2.2.2

VSCode version

1.97.2

Vue version

3.5.13

TypeScript version

5.7.3

System Info

System:
    OS: macOS 15.3
    CPU: (11) arm64 Apple M3 Pro
    Memory: 424.42 MB / 18.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.18.1 - ~/.nvm/versions/node/v20.18.1/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v20.18.1/bin/npm
    pnpm: 10.4.0 - ~/.nvm/versions/node/v20.18.1/bin/pnpm
  Browsers:
    Chrome: 133.0.6943.55
    Edge: 133.0.3065.59
    Safari: 18.3

package.json dependencies

Steps to reproduce

Create a component with slots get error message.
Resolved when slots defined with macro defineSlots

What is expected?

No errors

What is actually happening?

vue-tsc --noEmit

src/components/input/Input.vue:395:30 - error TS4081: Exported type alias '__VLS_Slots' has or is using private name '__VLS_0'.

395 & { leading?: (props: typeof __VLS_0) => any }
~~~~~~~

src/components/input/Input.vue:396:31 - error TS4081: Exported type alias '__VLS_Slots' has or is using private name '__VLS_1'.

396 & { trailing?: (props: typeof __VLS_1) => any }>;
~~~~~~~

src/components/modal/Modal.vue:338:30 - error TS4081: Exported type alias '__VLS_Slots' has or is using private name '__VLS_15'.

338 & { default?: (props: typeof __VLS_15) => any }>;
~~~~~~~~

Found 3 errors in 2 files.

Errors Files
2 src/components/input/Input.vue:395
1 src/components/modal/Modal.vue:338

Link to minimal reproduction

No response

Any additional comments?

i think this bug fix has something to do with it
#5139

@KazariEX
Copy link
Collaborator

Please provide a minimal reproduction.

@Xenossolitarius
Copy link
Author

https://github.com/Xenossolitarius/vue-tsc-2.2.2-bug

Here you go

pnpm i

pnpm typecheck

Should reproduce

src/components/modal/Modal.vue:338:30 - error TS4081: Exported type alias '__VLS_Slots' has or is using private name '__VLS_15'.

338 & { default?: (props: typeof __VLS_15) => any }>;
~~~~~~~~

@Xenossolitarius
Copy link
Author

Oh so the problem is if the slot is in v-if

@KazariEX
Copy link
Collaborator

This is more like a TS problem.

Image

We have been trying to simplify the code of codegen, but the results are always unsatisfactory😇

It would be better to use defineSlots instead of raw <slot>.

@KazariEX KazariEX changed the title [v2.2.2] Typecheck breaks on components with slots [v2.2.2] Typecheck breaks on slots in the v-if block Feb 16, 2025
@Xenossolitarius
Copy link
Author

Xenossolitarius commented Feb 16, 2025

tbh i hope SFC gets scrapped and we start using tsx/vine. I I think that would make your life much easier. Yea this would be a TS issue bcs this is basically how this works. But the type is available eh.

And this below produces "undefined" as a type too when i add the component to your repo. Seems more than one edge case.

<template>
	<div
	   v-if="open"
	>
	   <slot />
	</div>
</template>
  
<script setup lang="ts">
const open = true
</script>

<style scoped>
</style>

@KazariEX KazariEX marked this as a duplicate of #5187 Feb 17, 2025
@KazariEX
Copy link
Collaborator

@Xenossolitarius Does disabling the ts compiler option composite have any impact on your project?

sabertazimi added a commit to sabertazimi/awesome-web that referenced this issue Feb 17, 2025
sabertazimi added a commit to sabertazimi/awesome-web that referenced this issue Feb 17, 2025
* chore(deps): update dependencies (non-major)

* fix(vue-tsc):  use `defineSlots` instead of raw `<slot>`

See vuejs/language-tools#5186 (comment).

* fix(Tile): set default tile image to transparent

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: sabertazimi <sabertazimi@gmail.com>
github-actions bot added a commit to sabertazimi/awesome-web that referenced this issue Feb 17, 2025
* chore(deps): update dependencies (non-major)

* fix(vue-tsc):  use `defineSlots` instead of raw `<slot>`

See vuejs/language-tools#5186 (comment).

* fix(Tile): set default tile image to transparent

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: sabertazimi <sabertazimi@gmail.com> 67833ea
xmatthias added a commit to freqtrade/frequi that referenced this issue Feb 19, 2025
@Durss
Copy link

Durss commented Feb 21, 2025

If that can be of any help, I have a similar issue with an unused template ref

I have a node with a ref='xxx' attribute that wasn't actually used in the JS part of the SFC.
Running a type-check led to this error:

Property 'my_template_ref' of exported interface has or is using private name '__VLS_5'.

Removing the unused ref attribute solved the issue.

I didn't get this issue with v2.1.10 but I get it on v2.2.2

keenthekeen added a commit to keenthekeen/opd-toolkit that referenced this issue Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants