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

Option does not exist attribute 'label' #17087

Closed
1 task done
jibenziliao opened this issue Jun 13, 2019 · 3 comments
Closed
1 task done

Option does not exist attribute 'label' #17087

jibenziliao opened this issue Jun 13, 2019 · 3 comments

Comments

@jibenziliao
Copy link

jibenziliao commented Jun 13, 2019

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

Select 组件定制回填内容,在TypeScript下报错

the Select component has errors in TypeScript

<Select
        placeholder="Please select store"
        optionLabelProp="label"
        style={{ width: "100%" }}
      >
        {items.map(item => (
         // got an error for label attribute
          <Option key={item} value={item} label={item}>
            <div>
              <Avatar style={{ background: "#10899e" }}>{item[0]}</Avatar>{" "}
              {item}
            </div>
          </Option>
        ))}
      </Select>

What is expected?

antd/lib/select/index.d.ts OptionProps 缺少 label参数

antd/lib/select/index.d.ts OptionProps missing label param

export interface OptionProps {
    disabled?: boolean;
    value?: string | number;
    title?: string;
    children?: React.ReactNode;
    className?: string;
    style?: React.CSSProperties;
// label: string (missing)
}

What is actually happening?

const Option: React.ClassicComponentClass

不能将类型“{ children: Element; key: string; value: string; label: string; }”分配给类型“IntrinsicAttributes & IntrinsicClassAttributes<Component<OptionProps, any, any>> & Readonly & Readonly<{ children?: ReactNode; }>”.
类型“IntrinsicAttributes & IntrinsicClassAttributes<Component<OptionProps, any, any>> & Readonly & Readonly<{ children?: ReactNode; }>”上不存在属性“label”。ts(2322)

Environment Info
antd 3.19.3
React 16.8.6
System Mac OS 10.14.5
Browser Chrome 75.0.3770.80 (official) (x64)
@afc163
Copy link
Member

afc163 commented Jun 13, 2019

图片

@afc163
Copy link
Member

afc163 commented Jun 13, 2019

https://codesandbox.io/s/vibrant-grass-yrj8i

@afc163 afc163 closed this as completed Jun 13, 2019
@afc163
Copy link
Member

afc163 commented Jul 6, 2020

Duplicate of #17493

@afc163 afc163 marked this as a duplicate of #17493 Jul 6, 2020
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

3 participants