type-fest icon indicating copy to clipboard operation
type-fest copied to clipboard

Weird bug report - RangeError: Maximum call stack size exceeded when building

Open mvarchdev opened this issue 1 year ago • 2 comments

I forked this repo "https://github.com/bottenderjs/messaging-apis" because I need to change some of functionality and overall update of packages. Fork is here: https://github.com/sunray-eu/messaging-apis-custom/blob/9cc3f6a846203ffe6833e7aac0f987e3f84a913d/packages/messaging-api-common/src/case.ts#L210 -> In this package and file, there is issue when I upgrade to latest version that I cannot solve. When I upgrade 'type-fest' until 4.7.1, it works even without changing anything. When I upgrade to 4.8.0+, then it breaks and while build it shows this: RangeError: Maximum call stack size exceeded when building.

I managed to isolate issue to messaging-api-common package and to method in link above. I found these conditions when it work or not work:

  1. It works normally until '4.7.1' (Tested literally all versions between '1.4.0' and '4.7.1')
  2. When it is on '4.8.0+' then it breaks, I isolated issue in method pascalcaseKeys in the link above. When I remove this conditional typing and set it constantly either to PascalCasedPropertiesDeep or PascalCasedProperties, it works:
O['deep'] extends true
  ? PascalCasedPropertiesDeep<T>
  : PascalCasedProperties<T>

How to reproduce? just clone repo, set version of type-fest to 4.8.0 in messaging-api-common workspace and simply run yarn - it will run also yarn compile

My question is, if this is issue in type-fest or in implementation that code use. Also, how could I solve this with conditional checking kept?

Thanks in advance!

mvarchdev avatar Jan 28 '24 16:01 mvarchdev

Try newly released v4.10.2 and see if that helps. It dealt with such a problem in TypeScript 5.4

voxpelli avatar Jan 31 '24 11:01 voxpelli