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

Can't find children in FunctionComponent Props #4987

Closed
xg4 opened this issue Dec 2, 2019 · 4 comments
Closed

Can't find children in FunctionComponent Props #4987

xg4 opened this issue Dec 2, 2019 · 4 comments

Comments

@xg4
Copy link

xg4 commented Dec 2, 2019

问题描述

Can't find children in Taro.FunctionComponent props

复现步骤

import Taro from '@tarojs/taro'
import { View } from '@tarojs/components'

const Tag: Taro.FC = ({ children }) => {
  return <View>{children}</View>
}

export default Tag
// ts error:
// Property 'children' does not exist on type 'Readonly<{}>'.ts(2339)

期望行为

I can use children without declaration

报错信息

ts error:
Property 'children' does not exist on type 'Readonly<{}>'.ts(2339)

系统信息

Taro v1.3.
Taro CLI 1.3.26 environment info:

补充信息

@taro-bot
Copy link

taro-bot bot commented Dec 2, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@xg4
Copy link
Author

xg4 commented Dec 2, 2019

Can I use React.ReactNode to fix it?

// taro.component.d.ts
// 35 lines
  type PropsWithChildren<P> = Readonly<P> & { children?: React.ReactNode };

  interface FunctionComponent<P = {}> {
    (props: PropsWithChildren<P>): JSX.Element
    defaultProps?: Partial<P>
    config?: Config
    options?: ComponentOptions
  }

@shenghanqin
Copy link
Collaborator

请按照taro info提供完整的判断依据,并且给出一些您认为的参考依据,我们好做出更好的判断。

@taro-bot
Copy link

taro-bot bot commented Dec 2, 2019

Hello~

您的问题所提供的信息不足,我们无法定位到具体的问题。如果有空的话还请拔冗提供更具体的信息,否则这个 issue 将在 15 天后被自动关闭。

如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。

Good luck and happy coding~

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

No branches or pull requests

2 participants