gcanti / typelevel-ts

Type level programming in TypeScript
https://gcanti.github.io/typelevel-ts
MIT License
356 stars 12 forks source link

TS 2.5 regression #9

Closed KiaraGrouwstra closed 6 years ago

KiaraGrouwstra commented 7 years ago

It appear one of the TS 2.5 commits, maybe https://github.com/Microsoft/TypeScript/pull/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
...
> typelevel-ts@0.1.3 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 commented 7 years ago

@tycho01 thanks for pointing out. Working on a possible fix https://github.com/gcanti/typelevel-ts/pull/10

KiaraGrouwstra commented 7 years ago

Man, TupleLength and TupleToTHList are getting pretty hardcore! 😅

gcanti commented 7 years ago

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

https://github.com/gcanti/typelevel-ts/blob/df682c58b837b97aeaaf940f28de649f9d10ea96/src/index.ts#L5

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

https://github.com/gcanti/typelevel-ts/blob/df682c58b837b97aeaaf940f28de649f9d10ea96/src/index.ts#L289

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

KiaraGrouwstra commented 7 years ago

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 commented 7 years ago

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