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: Fix Route getComponent typing #246

Merged
merged 1 commit into from
Feb 25, 2019
Merged
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: 1 addition & 4 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,7 @@ declare module 'found' {
*/
getComponent?: (
match: RouteMatch,
) =>
| React.ComponentType<any>
| Promise<React.ComponentType<any>>
| Promise<JSX.Element>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i am really confused how having an extra type in a union can make dtslint fail. but i do think this type is wrong

Copy link
Member

Choose a reason for hiding this comment

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

i don't understand dtslint AT ALL. it also always uses tsc@next

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i mean this is a real error. i just have no idea how this caught it:

yarn run v1.13.0
$ dtslint types
Error: /Users/jjia/vendor/found/types/example-app/index.tsx:34:11
ERROR: 34:11  expect  TypeScript@next compile error:
Type '() => Promise<ComponentClass<any, any> | FunctionComponent<any> | Element | (() => Element)>' is not assignable to type '(match: RouteMatch) => ComponentClass<any, any> | FunctionComponent<any> | Promise<ComponentType<any>> | Promise<Element>'.
  Type 'Promise<ComponentClass<any, any> | FunctionComponent<any> | Element | (() => Element)>' is not assignable to type 'ComponentClass<any, any> | FunctionComponfix: Fix Route getComponent typing
ent<any> | Promise<ComponentType<any>> | Promise<Element>'.
    Type 'Promise<ComponentClass<any, any> | FunctionComponent<any> | Element | (() => Element)>' is not assignable to type 'Promise<ComponentType<any>>'.
      Type 'ComponentClass<any, any> | FunctionComponent<any> | Element | (() => Element)' is not assignable to type 'ComponentType<any>'.
        Type 'Element' is not assignable to type 'ComponentType<any>'.
          Type 'Element' is not assignable to type 'FunctionComponent<any>'.
            Type 'Element' provides no match for the signature '(props: any, context?: any): ReactElement<any> | null'.

) => React.ComponentType<any> | Promise<React.ComponentType<any>>;
/**
* additional data for the route
*/
Expand Down