universal-router icon indicating copy to clipboard operation
universal-router copied to clipboard

TypeScript 3.8.3: type checking failing

Open StefanJelner opened this issue 5 years ago • 9 comments

  • [x] bug report
  • [ ] feature request
  • [ ] other (Please do not submit support requests here (below))

Description: When compiling Universal Router with Typescript 3.8.3 i get the following type checking errors:

[tsl] ERROR in foo/node_modules/universal-router/src/UniversalRouter.ts(207,13)
      TS2322: Type '{ done: false; value: false | RouteMatch<R, C>; }' is not assignable to type 'IteratorResult<RouteMatch<R, C>, false>'.
  Type '{ done: false; value: false | RouteMatch<R, C>; }' is not assignable to type 'IteratorReturnResult<false>'.
    Types of property 'done' are incompatible.
      Type 'false' is not assignable to type 'true'.
foo/node_modules/universal-router/src/UniversalRouter.ts
[tsl] ERROR in foo/node_modules/universal-router/src/UniversalRouter.ts(291,68)
      TS2339: Property 'route' does not exist on type 'false | RouteMatch<R, C>'.
  Property 'route' does not exist on type 'false'.
foo/node_modules/universal-router/src/UniversalRouter.ts
[tsl] ERROR in foo/node_modules/universal-router/src/UniversalRouter.ts(294,81)
      TS2339: Property 'route' does not exist on type 'false | RouteMatch<R, C>'.
  Property 'route' does not exist on type 'false'.
foo/node_modules/universal-router/src/UniversalRouter.ts
[tsl] ERROR in foo/node_modules/universal-router/src/UniversalRouter.ts(299,65)
      TS2339: Property 'route' does not exist on type 'false | RouteMatch<R, C>'.
  Property 'route' does not exist on type 'false'.
foo/node_modules/universal-router/src/UniversalRouter.ts
[tsl] ERROR in foo/node_modules/universal-router/src/UniversalRouter.ts(314,69)
      TS2339: Property 'params' does not exist on type 'false | RouteMatch<R, C>'.
  Property 'params' does not exist on type 'false'.

Solution: I already fixed it and attached a git diff to this bug report. UniversalRouter.ts.txt

StefanJelner avatar Mar 19 '20 16:03 StefanJelner

Can you please share the code how you are using it, for example how your routes looks like?

frenzzy avatar Mar 20 '20 12:03 frenzzy

These errors are build errors, which are related to wrong or incomplete type declarations in your code, which have nothing to do with the way my routes look like. Please check the diff i made.

StefanJelner avatar Mar 23 '20 09:03 StefanJelner

I do not have any type errors in my codebase and I am not sure you solution is correct. Could you please share a minimal working example that I can reproduce the issue?

Maybe something wrong with tsconfig 🤷‍♂️

frenzzy avatar Mar 23 '20 11:03 frenzzy

It worked until i updated your library. So it must have to do with changes you made in your library. It is easy to reproduce. Use Typescript 3.8.3 and import your library. Actually the errors should come up. Already in your IDE if you use VSC.

StefanJelner avatar Mar 24 '20 10:03 StefanJelner

I just created a playground repo: https://github.com/frenzzy/universal-router-playground There are no type errors, could you please tell me what I should change to reproduce the issue?

frenzzy avatar Mar 24 '20 17:03 frenzzy

@StefanJelner any clue?

frenzzy avatar Mar 30 '20 13:03 frenzzy

@frenzzy reproduced example: https://github.com/frenzzy/universal-router-playground/pull/1

(Apologies for the additional noise in the PR, it was cut and paste from a larger project).

The issue only presents itself after the generateUrls import is added...

GordonSmith avatar Aug 15 '20 08:08 GordonSmith

@frenzzy hi, I have the same problem with typescript 4.2.4 and I can confirm that bug appears after generateUrls import is added. Do you have any idea how to fix it?

Lispython avatar May 21 '21 13:05 Lispython

@frenzzy i'm experiencing the same problem with typescript 4.4.4, when importing generateUrls - any news? @Lispython @GordonSmith @StefanJelner where you able to fix it in your project?

mbeckert avatar Oct 28 '21 09:10 mbeckert