Skip to content

Typings should support attributes like "className", "id"... in index.d.ts #7532

Closed
@noru

Description

Version

2.13.0

Environment

mac os, chrome

Reproduction link

https://github.com/ant-design/ant-design/blob/master/components/slider/index.tsx

Steps to reproduce

When assigning common component props like "className" to Slider:

<Slider className="some-class" ... />

, compiler would yield :

TS2339: Property 'className' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<BasicProps, ComponentState>> & Readonly<...'.

What is expected?

By assigning props like "id" or "className", there shouldn't be any TS2339 error.

What is actually happening?

Take Slider for example but there're more components which have similar issue.

inantd/lib/slider/index.d.ts:

export interface SliderProps {
    prefixCls?: string;
    tooltipPrefixCls?: string;
    range?: boolean;
   ...
}

The props interface should either extend React.HTMLAttributes or have a [props: string]: any, cause clearly in code it supports native/custom props:

return <RcSlider {...restProps} handle={this.handleWithTooltip} />;

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions