sindresorhus / ansi-escapes

ANSI escape codes for manipulating the terminal
MIT License
485 stars 44 forks source link

Type-fest TS errors when updating to tsc 4.8 #29

Closed curiousdannii closed 2 years ago

curiousdannii commented 2 years ago

My project depends on ansi-escapes@5.0.0. When I tried updating to tsc 4.8, I'm now getting these errors:

node_modules/type-fest/ts41/get.d.ts:95:37 - error TS2344: Type 'BaseType' does not satisfy the constraint 'Record<string | number, any>'.

95  : Key extends keyof WithStringKeys<BaseType>
                                       ~~~~~~~~

  node_modules/type-fest/ts41/get.d.ts:79:17
    79 type PropertyOf<BaseType, Key extends string> =
                       ~~~~~~~~
    This type parameter might need an `extends Record<string | number, any>` constraint.

node_modules/type-fest/ts41/get.d.ts:96:19 - error TS2344: Type 'BaseType' does not satisfy the constraint 'Record<string | number, any>'.

96  ? WithStringKeys<BaseType>[Key]
                     ~~~~~~~~

  node_modules/type-fest/ts41/get.d.ts:79:17
    79 type PropertyOf<BaseType, Key extends string> =
                       ~~~~~~~~
    This type parameter might need an `extends Record<string | number, any>` constraint.

Found 2 errors in the same file, starting at: node_modules/type-fest/ts41/get.d.ts:95

Would updating this package's type-fest version help? But I see that it updates the minimum TS version supported, so updating it might be a semver major change? Slightly messy.

curiousdannii commented 2 years ago

Thank you!

curiousdannii commented 6 months ago

I'm getting errors again when updated to Typescript 5.4.

node_modules/type-fest/source/merge-deep.d.ts:140:5 - error TS2321: Excessive stack depth comparing types 'PickRestType<ArrayTail<ArrayTail<Destination>>>[number]' and 'UnknownArrayOrTuple'.

140 > = [
        ~
141  ...DoMergeDeepTupleAndTupleRecursive<OmitRestType<Destination>, OmitRestType<Source>, PickRestTypeFlat<Destination>, PickRestTypeFlat<Source>, Options>,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
142  ...MergeDeepArrayOrTupleElements<PickRestType<Destination>, PickRestType<Source>, Options>,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
143 ];
    ~

Honestly, I'm only using this package for 4 of constants, not any of the functions. It might be best to just directly embed them in my project.

sindresorhus commented 6 months ago

I have inlined the needed TypeScript type, so this should not happen again.

https://github.com/sindresorhus/ansi-escapes/releases/tag/v6.2.1