[Feature Request] Export Props interface definition in all component index.d.ts files
See original GitHub issueWhat 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:
- Created 6 years ago
- Reactions:6
- Comments:9 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
I think the following is good enough: