Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upFeature/typescript prop exports #3448
Conversation
rvaidya
added some commits
Feb 5, 2019
This comment has been minimized.
This comment has been minimized.
taion
reviewed
Feb 5, 2019
taion
reviewed
Feb 5, 2019
@@ -12,7 +12,7 @@ declare class AlertHeading< | |||
As extends React.ReactType = 'div' | |||
> extends BsPrefixComponent<As> {} | |||
|
|||
interface AlertProps extends React.HTMLProps<Alert> { | |||
export interface AlertProps extends React.HTMLProps<Alert> { |
This comment has been minimized.
This comment has been minimized.
taion
Feb 5, 2019
Member
i guess we don't want the exported name for the individual modules here to be Props
?
This comment has been minimized.
This comment has been minimized.
rvaidya
Feb 5, 2019
Author
tslint recomments interfaces all start with I -> IAlertProps
if that is preferable
This comment has been minimized.
This comment has been minimized.
thejohnfreeman
Feb 9, 2019
@taion , your hunch is right. The general convention in the React community, including the react
package, is to use the name ComponentNameProps
instead of just Props
, to make imports of multiple props types easier.
This comment has been minimized.
This comment has been minimized.
The other pattern I've seen is to use a namespace but I'm not really familiar with what that would look like practically here |
thejohnfreeman
approved these changes
Feb 9, 2019
thejohnfreeman left a comment
LGTM. I've tested the changes with |
thejohnfreeman
suggested changes
Feb 13, 2019
@@ -1,7 +1,7 @@ | |||
import * as React from 'react'; | |||
import { TransitionCallbacks } from './helpers'; | |||
|
|||
interface CollapseProps | |||
export interface CollapseProps |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
rvaidya
Feb 13, 2019
•
Author
I noticed that too but it's not listed in the react-bootstrap docs, and also seems to work in some cases without the id prop
This comment has been minimized.
This comment has been minimized.
prateekkathal
Feb 13, 2019
@rvaidya The id prop is non-mandatory. Add these please
id?: string;
className?: string;
@thejohnfreeman I believe adding these 2 lines should do it
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
prateekkathal
Feb 14, 2019
@jquense Giving this one last try. Let me know if you're okay with this.... It fixes the issue. Otherwise someone else can take this in the future.
interface NavbarCollapseProps extends React.ClassAttributes<NavbarCollapse> {
id?: string;
className?: string;
}
declare class NavbarCollapse extends BsPrefixComponent<typeof Collapse, NavbarCollapseProps> {}
Thanks for the continued support on this
This comment has been minimized.
This comment has been minimized.
thejohnfreeman
Feb 14, 2019
NavbarCollapse
renders aCollapse
with adiv
child, and passes all its props besidesbsPrefix
through to theCollapse
.- The
Collapse
renders aTransition
with a child render function that renders the child ofCollapse
(thediv
).Collapse
takes out theclassName
prop, passing it through to its child. It passes its remaining unknown props through to theTransition
, which is imported fromreact-transition-group
. Transition
subtracts its props and passes the rest back to its render child.Collapse
defines a render child that passes these props through to its child (thediv
in this case).
So it seems that Collapse
should expect to get a mix of the props it knows it uses (already listed as properties in CollapseProps
), the props expected by Transition
(named TransitionCallbacks
, which CollapseProps
already extends), and the props of its child (the div
in this case, but could be anything). This last type is conceptually PropsOf<children>
, but I don't know how to express that in TypeScript.
This comment has been minimized.
This comment has been minimized.
jquense
Feb 14, 2019
Member
ya I think what we actually need to do long term is change the API here so each component doesn't just pass through everything to it's children
This comment has been minimized.
This comment has been minimized.
thejohnfreeman
Feb 14, 2019
@prateekkathal , I'm with @jquense and think you should leave the type fixing out of this PR, especially since it's so complicated. Just getting proper exports is a great step forward.
This comment has been minimized.
This comment has been minimized.
rvaidya
dismissed
taion’s
stale review
via
57278de
Feb 14, 2019
This comment has been minimized.
This comment has been minimized.
jviall
commented
Feb 15, 2019
Is a different issue/PR going to be opened for the lack of |
rvaidya commentedFeb 5, 2019