arcanis / clipanion

Type-safe CLI library / framework with no runtime dependencies
https://mael.dev/clipanion/
1.11k stars 64 forks source link

Clipanion doesn't work with TypeScript 4.8 #127

Closed tmkn closed 1 year ago

tmkn commented 2 years ago

The latest version of clipanion (3.2.0-rc.11) doesn't work with the latest version of TypeScript (4.8).

Reproduce

  1. Use clipanion@3.2.0-rc11
  2. Use TypeScript@4.8.2
  3. Enable strictNullChecks in your code
  4. Compile

Expected Result

Compiles fine

Result

Clipanion type check errors.

It's due to stricter generic check introduced in 4.8: https://devblogs.microsoft.com/typescript/announcing-typescript-4-8/#unconstrained-generics-no-longer-assignable-to

Unconstrained Generics No Longer Assignable to {}

In TypeScript 4.8, for projects with strictNullChecks enabled, TypeScript will now correctly issue an error when an unconstrained type parameter is used in a position where null or undefined are not legal values. That will include any type that expects {}, object, or an object type with all-optional properties.

Clipanion now errors because the first parameter of WithArity is restricted with Type extends { length?: number; } clipanion3 But in a lot of places it gets non restricted generics clipanion2

Which results in these errors: clipanion1

It's possible to bypass this for now with skipLibCheck but unfortunately this turns off type checking for all libraries.

e: Looks like adding extends {} like so gets rid of the errors: clipanion4 However I cannot setup the dev environment to create a PR

Ayc0 commented 1 year ago

A fix was shipped in https://github.com/arcanis/clipanion/pull/131 (version 3.2.0-rc.14)

tmkn commented 1 year ago

👏 can confirm, works fine again