Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

TS 2.5 regression #9

Closed
KiaraGrouwstra opened this issue Aug 12, 2017 · 5 comments
Closed

TS 2.5 regression #9

KiaraGrouwstra opened this issue Aug 12, 2017 · 5 comments

Comments

@KiaraGrouwstra
Copy link

KiaraGrouwstra commented Aug 12, 2017

It appear one of the TS 2.5 commits, maybe microsoft/TypeScript#17455, made type checks significantly stricter, which pretty much just broke typelevel-ts (as well as my my typical, if instead with error Type <generic> cannot be used to index type <array>).

Here is the output running tests on 2.5.0-dev.20170808:

$ npm test
...
> [email protected] typings-checker /media/tycho/Drogon/Coding/js/typelevel-ts
> typings-checker --allow-expect-error --project typings-checker/tsconfig.json typings-checker/index.ts

typings-checker/index.ts:98: Unexpected error
  Type 'N1' does not satisfy the constraint 'Positive'.
  Type 'Nat' is not assignable to type 'Positive'.
    Property 'prev' is optional in type 'Nat' but required in type 'Positive'.

typings-checker/index.ts:98: Unexpected error
  Type 'N2' does not satisfy the constraint 'Positive'.
  Type 'Nat' is not assignable to type 'Positive'.

typings-checker/index.ts:104: Unexpected error
  Type 'N1' does not satisfy the constraint 'Positive'.
  Type 'Nat' is not assignable to type 'Positive'.

typings-checker/index.ts:114: Unexpected error
  Type 'N1' does not satisfy the constraint 'Positive'.
  Type 'Nat' is not assignable to type 'Positive'.

typings-checker/index.ts:114: Unexpected error
  Type 'N2' does not satisfy the constraint 'Positive'.
  Type 'Nat' is not assignable to type 'Positive'.

typings-checker/index.ts:120: Unexpected error
  Type 'N1' does not satisfy the constraint 'Positive'.
  Type 'Nat' is not assignable to type 'Positive'.

typings-checker/index.ts:120: Unexpected error
  Type 'N2' does not satisfy the constraint 'Positive'.
  Type 'Nat' is not assignable to type 'Positive'.

typings-checker/index.ts:127: Unexpected error
  Type 'N1' does not satisfy the constraint 'Positive'.
  Type 'Nat' is not assignable to type 'Positive'.

typings-checker/index.ts:128: Unexpected error
  Type 'N1' does not satisfy the constraint 'Positive'.

typings-checker/index.ts:234: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.
  Type 'THList' is not assignable to type 'THCons<any, any>'.
    Type 'THNil' is not assignable to type 'THCons<any, any>'.
      Types of property 'IsHNil' are incompatible.
        Type '"true"' is not assignable to type '"false"'.

typings-checker/index.ts:238: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.
  Type 'THList' is not assignable to type 'THCons<any, any>'.
    Type 'THNil' is not assignable to type 'THCons<any, any>'.

typings-checker/index.ts:239: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:239: Unexpected error
  Type 'I' does not satisfy the constraint 'Positive'.
  Type 'Nat' is not assignable to type 'Positive'.

typings-checker/index.ts:245: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.
  Type 'THList' is not assignable to type 'THCons<any, any>'.
    Type 'THNil' is not assignable to type 'THCons<any, any>'.

typings-checker/index.ts:246: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:246: Unexpected error
  Type 'I' does not satisfy the constraint 'Positive'.
  Type 'Nat' is not assignable to type 'Positive'.

typings-checker/index.ts:251: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.
  Type 'THList' is not assignable to type 'THCons<any, any>'.
    Type 'THNil' is not assignable to type 'THCons<any, any>'.

typings-checker/index.ts:252: Unexpected error
  Type 'I' does not satisfy the constraint 'Positive'.
  Type 'Nat' is not assignable to type 'Positive'.

typings-checker/index.ts:252: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:257: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.
  Type 'THList' is not assignable to type 'THCons<any, any>'.
    Type 'THNil' is not assignable to type 'THCons<any, any>'.

typings-checker/index.ts:257: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:257: Unexpected error
  Type 'Acc' does not satisfy the constraint 'THList'.
  Type 'Acc' is not assignable to type 'THCons<any, any>'.

typings-checker/index.ts:262: Unexpected error
  A tuple type element list cannot be empty.

typings-checker/index.ts:264: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.
  Type 'THList' is not assignable to type 'THCons<any, any>'.
    Type 'THNil' is not assignable to type 'THCons<any, any>'.

typings-checker/index.ts:266: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:266: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:268: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:268: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:268: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:271: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:272: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:273: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:274: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:278: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:279: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:280: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:281: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:282: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:286: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:287: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:288: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:289: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:290: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:291: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:294: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:295: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:296: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:297: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:298: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:299: Unexpected error
  Type 'L' does not satisfy the constraint 'THCons<any, any>'.

typings-checker/index.ts:311: Unexpected error
  Type 'I' cannot be used to index type '[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]'.

typings-checker/index.ts:313: Unexpected error
  Type 'I' does not satisfy the constraint 'string'.

typings-checker/index.ts:316: Unexpected error
  Type 'I' cannot be used to index type '[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]'.

typings-checker/index.ts:316: Unexpected error
  Type 'I' cannot be used to index type 'T'.

typings-checker/index.ts:316: Unexpected error
  Type 'L' does not satisfy the constraint 'THList'.
  Type 'L' is not assignable to type 'THCons<any, any>'.

typings-checker/index.ts:318: Unexpected error
  Type 'I' does not satisfy the constraint 'string'.

typings-checker/index.ts: 3 / 59 checks passed.
@gcanti
Copy link
Owner

gcanti commented Aug 12, 2017

@tycho01 thanks for pointing out. Working on a possible fix #10

@KiaraGrouwstra
Copy link
Author

KiaraGrouwstra commented Aug 12, 2017

Man, TupleLength and TupleToTHList are getting pretty hardcore! 😅

@gcanti
Copy link
Owner

gcanti commented Aug 13, 2017

Indeed, those types are going out of control. Changing the Increment definition to a string -> string mapping

export type Increment = { 0: '1'; 1: '2'; 2: '3'; 3: '4'; 4: '5'; 5: '6'; 6: '7'; 7: '8'; 8: '9'; 9: '10'; 10: never }

seems to work better and I can switch back to compact definitions

export type TupleToHList<T extends [any], I extends keyof Increment & keyof T = '0', L extends HList = HNil> = {

Still I'm not able to convert a number to a string

@KiaraGrouwstra
Copy link
Author

Yeah, NumberToString appears the bottleneck there now that microsoft/TypeScript#15768 got worse with the stricter checks in 2.5.
Pretty good workaround you got there though!
I'm currently checking if I could just fix that (and some more) at the compiler level. Feel like I've been complaining more than contributing so far so yeah.

@KiaraGrouwstra
Copy link
Author

Oh, I just got a PR in to fix 17455, so numbers may become more usable again (except for things like keyof). 😃

@gcanti gcanti closed this as completed Sep 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants