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

fix: TS types on Router children components #395

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ export function Route<Props>(
export function Link(props: {activeClassName?: string} & preact.JSX.HTMLAttributes): preact.VNode;

declare module 'preact' {
export interface Attributes extends RoutableProps {}
namespace JSX {
interface IntrinsicAttributes extends RoutableProps {}
}
interface Attributes extends RoutableProps {}
}

export default Router;
12 changes: 9 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"rimraf": "^2.5.1",
"sinon": "^7.1.0",
"sinon-chai": "^2.8.0",
"typescript": "^3.4.4",
"typescript": "4.0.5",
"webpack": "^4.42.0"
}
}
5 changes: 5 additions & 0 deletions test/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ const SomeFunctionalComponent: FunctionalComponent<{}> = ({}) => {
return <div></div>;
};

function FunctionalComponentWithoutAnnotation() {
return <div />;
}

function RouterWithComponents() {
return (
<Router>
<div default></div>
<ClassComponent default />
<SomeFunctionalComponent default />
<FunctionalComponentWithoutAnnotation default />
<div path="/a"></div>
<ClassComponent path="/b" />
<SomeFunctionalComponent path="/c" />
Expand Down