Ant-design: [Feature Request] Export Props interface definition in all component index.d.ts files

Created on 23 Jun 2017  ·  8Comments  ·  Source: ant-design/ant-design

What problem does this feature solve?

Having standard Props interface defined as public makes it possible to reuse the Props definition when creating my own custom version of the component.

What does the proposed API look like?

For example, when creating my Login Component, I must:

import { FormComponentProps } from 'antd/lib/form/Form'

class Login extends React.Component<{} & FormComponentProps, {}> {
  render() {
    // some render code
  }
}

But following maybe better:

import { FormComponentProps } from 'antd'

class Login extends React.Component<{} & FormComponentProps, {}> {
  render() {
    // some render code
  }
}

At least:

import { FormComponentProps } from 'antd/lib/form'

class Login extends React.Component<{} & FormComponentProps, {}> {
  render() {
    // some render code
  }
}

Just like this TS based UI package does: blueprint

help wanted 🗣 Discussion

Most helpful comment

I think the first one is better.

Choosing the second way may be because the first one exposed too may interfaces, but these interfaces are very useful when using TypeScript, those who do not use TS simply do not see them.

Many of the frameworks written in TS will expose the interface to the outermost, and do not find any problems.

Of course, the second way can meet the needs. The purpose of this ISSUE is to unify the exposed location of the interface. The current situation is that the location of the interface is unpredictable in the lib/[component name]/ folder.

But I still hope that the first could be adopted, thanks.

All 8 comments

I think the following is good enough:

import { FormComponentProps } from 'antd/lib/form'

class Login extends React.Component<{} & FormComponentProps, {}> {
  render() {
    // some render code
  }
}

I think the first one is better.

Choosing the second way may be because the first one exposed too may interfaces, but these interfaces are very useful when using TypeScript, those who do not use TS simply do not see them.

Many of the frameworks written in TS will expose the interface to the outermost, and do not find any problems.

Of course, the second way can meet the needs. The purpose of this ISSUE is to unify the exposed location of the interface. The current situation is that the location of the interface is unpredictable in the lib/[component name]/ folder.

But I still hope that the first could be adopted, thanks.

Hi, im trying to figure out why is not working for me but, i have this error node_modules/antd/lib/form/index"' has no exported member 'FormComponentProps'.

my workaround was import { FormComponentProps } from 'antd/lib/form/Form';

What im doing wrong ?

@DavidNorena

Do you mean you try this: import { FormComponentProps } from 'antd/lib/form, but get an error?

of course it's an error, becauseFormComponentProps doesn't exposed in lib/form dir now, that's why I submit this issue :)

@newraina ahhhh now I get it ! :D sorry, so meanwhile i'll use import { FormComponentProps } from 'antd/lib/form/Form'; ok ?

@DavidNorena Yes

You can help us for this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

longhuasishen picture longhuasishen  ·  3Comments

taikongfeizhu picture taikongfeizhu  ·  3Comments

yangbin1994 picture yangbin1994  ·  3Comments

PeteAndersen picture PeteAndersen  ·  3Comments

ryannealmes picture ryannealmes  ·  3Comments