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

Correct typing in the indexServerSide test #586

Open
4 tasks
lomky opened this issue Dec 22, 2021 · 0 comments
Open
4 tasks

Correct typing in the indexServerSide test #586

lomky opened this issue Dec 22, 2021 · 0 comments
Labels
Engineering Technology and Development Track Type: Robustness Tickets to improve the application, invisibly
Milestone

Comments

@lomky
Copy link
Contributor

lomky commented Dec 22, 2021

Description

Correct the typing errors in the indexServerSide test. Due to the interaction between NextJS & Jest the typing is reporting issues, and due to how the context object is updated via the call, we cannot cast it to unknown.

Discovered & spun out of #571

$ yarn typecheck
$ tsc -p .
tests/pages/indexServerSide.test.ts:30:11 - error TS2322: Type 'GetServerSidePropsResult<{ [key: string]: any; }>' is not assignable to type 'GetServerSideProps<{ [key: string]: any; }, ParsedUrlQuery>'.
  Type '{ redirect: Redirect; }' is not assignable to type 'GetServerSideProps<{ [key: string]: any; }, ParsedUrlQuery>'.
    Type '{ redirect: Redirect; }' provides no match for the signature '(context: GetServerSidePropsContext<ParsedUrlQuery>): Promise<GetServerSidePropsResult<{ [key: string]: any; }>>'.

30     const result: GetServerSideProps = await getServerSideProps(context as GetServerSidePropsContext)
             ~~~~~~

tests/pages/indexServerSide.test.ts:30:65 - error TS2352: Conversion of type '{ req: { headers: {}; }; res: { statusCode: null; }; }' to type 'GetServerSidePropsContext<ParsedUrlQuery>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
  Type '{ req: { headers: {}; }; res: { statusCode: null; }; }' is missing the following properties from type 'GetServerSidePropsContext<ParsedUrlQuery>': query, resolvedUrl

30     const result: GetServerSideProps = await getServerSideProps(context as GetServerSidePropsContext)
                                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/pages/indexServerSide.test.ts:31:37 - error TS2339: Property 'props' does not exist on type 'GetServerSideProps<{ [key: string]: any; }, ParsedUrlQuery>'.

31     const props: HomeProps = result.props as HomeProps
                                       ~~~~~


Found 3 errors.

Acceptance Criteria

  • All typing in indexServerSide test is corrected
  • Remove //@ts-ignores & corresponding @typescript-eslint/ban-ts-comment comments from indexServerSide test
  • Tests continue to function
  • App continues to function
@lomky lomky added Engineering Technology and Development Track Type: Robustness Tickets to improve the application, invisibly labels Dec 22, 2021
@lomky lomky added this to the Low Priority milestone Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Engineering Technology and Development Track Type: Robustness Tickets to improve the application, invisibly
Projects
None yet
Development

No branches or pull requests

1 participant