-
Notifications
You must be signed in to change notification settings - Fork 5
Add TypeScript types #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { type FunctionComponentElement, type ProviderProps, type PropsWithChildren } from "react"; | ||
|
||
interface Options { | ||
debounce?: boolean, | ||
events?: Record<string, Array<string>> | ||
modelTypes?: Record<string, object>, | ||
withRef?: boolean | ||
} | ||
|
||
export declare function connectBackboneToReact<Model extends {}, ModelProps extends {}>( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naming nit: shouldn't this be |
||
mapModelToProps: (models: Model, props: ModelProps) => Partial<ModelProps>, options?: Options | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another naming nit: it should be |
||
): <CombinedProps>( | ||
wrappedComponent: React.ComponentType<CombinedProps> | ||
) => React.ComponentType<Omit<CombinedProps, keyof ModelProps>>; | ||
Comment on lines
+10
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think Compared to what I had written in the JIRA ticket: function connectBackboneToReact<Models extends {}, ModelProps extends {}>(
mapModelsToProps: (models: Models) => ModelProps
): <CombinedProps>(
WrappedComponent: React.ComponentType<CombinedProps>
) => React.ComponentType<Omit<CombinedProps, keyof ModelProps>>; In that definition, |
||
|
||
|
||
interface BackboneProviderProps<Models> { | ||
models: Models | ||
} | ||
|
||
export declare function BackboneProvider<Models extends {}>(props: PropsWithChildren<BackboneProviderProps<Models>>): FunctionComponentElement<ProviderProps<Models>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could probably be more specific than
string
, to limit it tokeyof Models
. Up to you if you think that's worth it though.