vuejs / core

🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
https://vuejs.org/
MIT License
47.47k stars 8.3k forks source link

Parameter 'context' implicitly has an 'any' type #10880

Open zch233 opened 5 months ago

zch233 commented 5 months ago

Vue version

3.4.21

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-rcbytc?file=src%2Fcomponents%2FHelloWorld.tsx

Steps to reproduce

when i used Function Signature with error

image

What is expected?

No errors

What is actually happening?

Parameter 'context' implicitly has an 'any' type

System Info

System:
    OS: macOS 13.6.7
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 29.79 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.7.3 - ~/.nvm/versions/node/v21.7.3/bin/node
    npm: 10.5.0 - ~/.nvm/versions/node/v21.7.3/bin/npm
    pnpm: 9.0.6 - /usr/local/bin/pnpm
    bun: 1.0.25 - ~/.bun/bin/bun
  npmPackages:
    vue: ^3.4.21 => 3.4.21

Any additional comments?

No response

kRaviteja7 commented 5 months ago

hi, can i work on this issue?

kRaviteja7 commented 5 months ago

Try this it's working, This issue file is not presented in the project?

import { ref, defineComponent, SetupContext } from 'vue';

export default defineComponent( <T extends string | number>(props: { msg: T; list: T[] }, context: SetupContext) => { const count = ref(0); console.log(props, context),

return () => {
  return <div>{count.value}</div>;
};

}, { props: ['msg', 'list'], } );

yangliguo7 commented 3 months ago

@zch233

不需要指定T类型,你可以看下这个函数类型定义。

https://github.com/vuejs/core/blob/main/packages/runtime-core/src/apiDefineComponent.ts#L123-L154

image
wjx25zj commented 2 months ago

same problem and "generics" don't work