FxTS icon indicating copy to clipboard operation
FxTS copied to clipboard

TS2589: Type instantiation is excessively deep and possibly infinite.

Open sfsepark opened this issue 4 years ago • 4 comments

Bug Report

typescript 4.5.2 이상에서 타입추론과 관련된 버그가 발생되고 있습니다.

node_modules/@fxts/core/dist/types/juxt.d.ts:33:76 - error TS2321: Excessive stack depth comparing types 'And<ParameterTuples<FS, []>, ParameterTuples<FS, []>[0]>' and 'any[] & And<ParameterTuples<FS, []>, ParameterTuples<FS, []>[0]>'.

33 declare function juxt<FS extends Arrow[]>(fs: [...FS] | readonly [...FS]): (...args: JuxtArgs<FS>) => JuxtReturnTypes<JuxtArgs<FS>, FS>;
                                                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@fxts/core/dist/types/juxt.d.ts:33:76 - error TS2321: Excessive stack depth comparing types 'And<Tail<ParameterTuples<FS, []>>, ParameterTuples<FS, []>[0]>' and 'any[] & And<Tail<ParameterTuples<FS, []>>, ParameterTuples<FS, []>[0]>'.

33 declare function juxt<FS extends Arrow[]>(fs: [...FS] | readonly [...FS]): (...args: JuxtArgs<FS>) => JuxtReturnTypes<JuxtArgs<FS>, FS>;
                                                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@fxts/core/dist/types/juxt.d.ts:33:76 - error TS2321: Excessive stack depth comparing types 'And<Tail<Tail<ParameterTuples<FS, []>>>, ParameterTuples<FS, []>[0] & Tail<ParameterTuples<FS, []>>[0]>' and 'any[] & And<Tail<Tail<ParameterTuples<FS, []>>>, ParameterTuples<FS, []>[0] & Tail<ParameterTuples<FS, []>>[0]>'.

33 declare function juxt<FS extends Arrow[]>(fs: [...FS] | readonly [...FS]): (...args: JuxtArgs<FS>) => JuxtReturnTypes<JuxtArgs<FS>, FS>;
                                                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@fxts/core/dist/types/juxt.d.ts:33:76 - error TS2321: Excessive stack depth comparing types 'And<Tail<Tail<Tail<ParameterTuples<FS, []>>>>, ParameterTuples<FS, []>[0] & Tail<ParameterTuples<FS, []>>[0] & Tail<...>[0]>' and 'any[] & And<Tail<Tail<Tail<ParameterTuples<FS, []>>>>, ParameterTuples<FS, []>[0] & Tail<ParameterTuples<FS, []>>[0] & Tail<...>[0]>'.

33 declare function juxt<FS extends Arrow[]>(fs: [...FS] | readonly [...FS]): (...args: JuxtArgs<FS>) => JuxtReturnTypes<JuxtArgs<FS>, FS>;
                                                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@fxts/core/dist/types/juxt.d.ts:33:76 - error TS2321: Excessive stack depth comparing types 'And<Tail<Tail<Tail<Tail<ParameterTuples<FS, []>>>>>, ParameterTuples<FS, []>[0] & Tail<ParameterTuples<FS, []>>[0] & Tail<...>[0] & Tail<...>[0]>' and 'any[] & And<Tail<Tail<Tail<Tail<ParameterTuples<FS, []>>>>>, ParameterTuples<FS, []>[0] & Tail<ParameterTuples<FS, []>>[0] & Tail<...>[0] & Tail<...>[0]>'.

33 declare function juxt<FS extends Arrow[]>(fs: [...FS] | readonly [...FS]): (...args: JuxtArgs<FS>) => JuxtReturnTypes<JuxtArgs<FS>, FS>;
                                                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@fxts/core/dist/types/juxt.d.ts:33:76 - error TS2321: Excessive stack depth comparing types 'And<Tail<Tail<Tail<Tail<Tail<ParameterTuples<FS, []>>>>>>, ParameterTuples<FS, []>[0] & Tail<ParameterTuples<FS, []>>[0] & Tail<...>[0] & Tail<...>[0] & Tail<...>[0]>' and 'any[] & And<Tail<Tail<Tail<Tail<Tail<ParameterTuples<FS, []>>>>>>, ParameterTuples<FS, []>[0] & Tail<...>[0] & Tail<...>[0] & Tail<...>[0] & Tail<...>[0]>'.

33 declare function juxt<FS extends Arrow[]>(fs: [...FS] | readonly [...FS]): (...args: JuxtArgs<FS>) => JuxtReturnTypes<JuxtArgs<FS>, FS>;
                                                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@fxts/core/dist/types/juxt.d.ts:33:76 - error TS2321: Excessive stack depth comparing types 'ParameterTuples<FS, []>[0] & Tail<ParameterTuples<FS, []>>[0]' and 'any[] & ParameterTuples<FS, []>[0] & Tail<ParameterTuples<FS, []>>[0]'.

33 declare function juxt<FS extends Arrow[]>(fs: [...FS] | readonly [...FS]): (...args: JuxtArgs<FS>) => JuxtReturnTypes<JuxtArgs<FS>, FS>;
                                                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@fxts/core/dist/types/juxt.d.ts:33:76 - error TS2589: Type instantiation is excessively deep and possibly infinite.

33 declare function juxt<FS extends Arrow[]>(fs: [...FS] | readonly [...FS]): (...args: JuxtArgs<FS>) => JuxtReturnTypes<JuxtArgs<FS>, FS>;
                                                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

💻 Code


interface Data{
  key : string;
  target : any;
}

const datas: Data[] = [ { key : 'A', target : { happy : 1 } } , { key : 'B', target : { happy : 2 } } ];

const dict = pipe(
    datas,
    indexBy(({ key }) => key),
    entries,
    map<Iterable<[string, Data]>, [string, any]>(([key, { target }]) => [key, target]),
    fromEntries,
  );

🙁 Actual behavior

타입 에러로 인하여 컴파일 되지 않음

🙂 Expected behavior

정상적인 컴파일 기대


Version Information

  • Operating system: Mac 12.0.1
  • Typescript: 4.2.3
  • Nodejs: 16.13.1

sfsepark avatar Mar 28 '22 02:03 sfsepark

It's similar to the recent issues I've experienced. We'll try to fix it. Thank you for your report.

hg-pyun avatar Mar 28 '22 13:03 hg-pyun

@sfsepark Let me know the tsconfig.json you set up? and check strict: true https://www.typescriptlang.org/tsconfig#strict

ppeeou avatar Mar 28 '22 15:03 ppeeou

As @ppeeou said, turning on the strict: true option should be fine.

https://codesandbox.io/s/mystifying-northcutt-27xf3s?file=/src/index.ts

shine1594 avatar Mar 29 '22 05:03 shine1594

@sfsepark could you check this issue??

ppeeou avatar Apr 14 '22 04:04 ppeeou

It appears to have been resolved.

ppeeou avatar Mar 10 '24 02:03 ppeeou