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

component type error #1996

Closed
HodgeWen opened this issue Oct 12, 2022 · 14 comments
Closed

component type error #1996

HodgeWen opened this issue Oct 12, 2022 · 14 comments
Labels
bug Something isn't working

Comments

@HodgeWen
Copy link

BUG report

When <script lang="ts" setup> and normal <script lang="ts"> are used together. it's report:
Type '{}' is not assignable to type 'ComponentProps<() => ComponentPublicInstanceConstructor<{ $: ComponentInternalInstance; $data: {}; $props: Partial<{}> & Omit<Readonly<ExtractPropTypes<{}>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>; ... 10 more ...; $watch(source: string | Function, cb: Function, options?: WatchOptions<......'.

<!-- ComponentWithMultipleRoots -->
<template>
  <div></div>
  <div></div>
</template>

<script lang="ts" setup>
//...
</script>

<script lang="ts">
export default {
   inheritAttrs: false
}
</script>
<template>
  <ComponentWithMultipleRoots />
</template>

image

ENV

Typescript version: 4.8.4
vite version: 3.1.7
volar version: 1.0.5
vscode version: 1.72
os: 5.17.15-1-MANJARO(x64)

@appleaway
Copy link

回滚volar到1.0.3版本等待解决吧

@jahnli
Copy link

jahnli commented Oct 12, 2022

the same problem

@DevilTea
Copy link

Here is a reproduction repo

when open the App.vue file with vscode,
the component props error message would show like below
image

when the component has both <script setup> and <script> with export default defineComponent({}) existed
image

@tanghaojie
Copy link

same error

@HodgeWen
Copy link
Author

回滚volar到1.0.3版本等待解决吧

回滚有效, 不过最近volar似乎不是很稳定.

@kyumoon
Copy link

kyumoon commented Oct 12, 2022

+1

@JoostKersjes
Copy link

Same here, all my components components with inheritAttrs: false are throwing this error.

@johnsoncodehk johnsoncodehk added the bug Something isn't working label Oct 12, 2022
@Fuphoenixes
Copy link

回滚volar到1.0.3版本等待解决吧

回滚有效, 不过最近volar似乎不是很稳定.

+1

@MrCube42
Copy link

MrCube42 commented Oct 12, 2022

In my case, these errors appear when calling methods defined via options API, e.g. this.myMethod(). I could workaround this in some cases by changing data() { ... to data: () =>. In this case, the type is correctly inferred. However, when I want to access the props in data and I need to change to data: (vm) => vm.myProp the inference is also broken.

Side note: The same errors appear also when building with vue-cli as soon as I switch from vue 2.7.10 to 2.7.11. As long as I stay on 2.7.10 this is only an IDE problem with Volar (vuejs/vue#8721 (comment)).

@vis97c
Copy link

vis97c commented Oct 14, 2022

Was this really fixed? I'm getting: type {name: string} is not assignable to type ComponentProps when working with transition components.

image

@MrCube42
Copy link

Problem (#1996 (comment)) still applies for me even after "fix" with 1.0.6.

@dxps
Copy link

dxps commented Nov 21, 2022

Same case here (the issue still exists): using Volar v1.0.9 (with takeover mode enabled, ofc) and this example.

It compiles and runs fine, it's just complaining about this:

Type '{ width: string; }' is not assignable to type 'ComponentProps<string>'.
  Type '{ width: string; }' is not assignable to type 'string'.ts(2322)

image

@Andrii-Khoptii
Copy link

Andrii-Khoptii commented Feb 27, 2023

The issue is still open

Volar ts: 1.2.0
Volar 1.2.0
Vite: 3.2.4

@hkochniss
Copy link

hkochniss commented Apr 15, 2023

@johnsoncodehk this creates massive type errors in vue-tsc 1.3.10, somehow VS Code Volar 1.3.14 doesn't show the errors though. We can't basically use vue-tsc right now, as it emits too many wrong errors, along the lines of (for a component with a simple 'id' prop) showing (only in vue.tsc, not VS Code)

Argument of type '{ id: string; }' is not assignable to parameter of type '{ ref?: VNodeRef | undefined; key?: string | number | symbol | undefined; ref_for?: boolean | undefined; ref_key?: string | undefined; onVnodeBeforeMount?: VNodeMountHook | VNodeMountHook[] | undefined;

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