Skip to content
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

feat: createBaseRouter in TS #1022

Merged
merged 4 commits into from
Dec 27, 2022
Merged

feat: createBaseRouter in TS #1022

merged 4 commits into from
Dec 27, 2022

Conversation

golota60
Copy link
Collaborator

@golota60 golota60 commented Dec 22, 2022

This one was the most painful to do :P

src/Redirect.tsx Outdated
Comment on lines 42 to 45
class RedirectType extends React.Component<RedirectOptions> {
// @ts-ignore
constructor(config: RedirectOptions);
}
Copy link
Collaborator Author

@golota60 golota60 Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know whether there's a better way to do this. The problem is i need consumer(the user of the library) to think this component extends React.Component but I don't want to actually extend

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is ok but maybe do:

declare class RedirectType extends React.Component<RedirectOptions> {
  constructor(config: RedirectOptions);
}

with the declare which should make it just a type?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, it works 😄

Comment on lines +8 to +12
path?: string;

to: string | ((match: Match) => LocationDescriptor);

status?: number;
Copy link
Collaborator Author

@golota60 golota60 Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to just declare fields on classes. Technically those are functional changes, but practically they should not change anything. I'm pretty sure the only difference is that this has those initialized as undefined when creating the instance, which should not change anything

Copy link
Member

@jquense jquense left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jquense
Copy link
Member

jquense commented Dec 27, 2022

Nice work, I was dreading these weird objects :P

@golota60 golota60 merged commit 92425ca into master Dec 27, 2022
@golota60 golota60 deleted the sw/idk-ts branch December 27, 2022 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants