question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
newrainacommented, Jul 18, 2017

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.

3reactions
benjycuicommented, Jun 28, 2017

I think the following is good enough:

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

class Login extends React.Component<{} & FormComponentProps, {}> {
  render() {
    // some render code
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Modules .d.ts - TypeScript
Comparing JavaScript to an example DTS. Common CommonJS Patterns. A module using CommonJS patterns uses module.exports to describe the exported values.
Read more >
Understanding and using interfaces in TypeScript
In this file, we can define any interfaces and types we plan on using throughout the application. export interface Post { title: string...
Read more >
Announcing TypeScript 4.7 - Microsoft Developer Blogs
When a file is considered an ES module, a few different rules come into play compared to CommonJS: import / export statements can...
Read more >
How to declare and import typescript interfaces in a separate file
You need to export the interface from the file in which is defined and import it wherever you want to use it. in...
Read more >
TypeScript: Adding Custom Type Definitions for Existing ...
Before you write custom types, you need to tell the transpiler about them. To do this you should edit the tsconfig.json file, and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found