Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Type instantiation is excessively deep and possibly infinite" error with large Enum values. #234

Closed
hg-pyun opened this issue Oct 4, 2023 · 1 comment · Fixed by #258 or #259
Closed
Labels
bug Something isn't working

Comments

@hg-pyun
Copy link
Collaborator

hg-pyun commented Oct 4, 2023

Bug Report

Using a large number of enum results in an error.

💻 Code

https://codesandbox.io/s/eager-frost-69nrn9?file=/src/App.tsx:0-751

import { pipe, find } from "@fxts/core";

export default function App() {
  return null;
}

enum Code {
  _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7,
  _8,
  _9,
  _10,
  _11,
  _12,
  _13,
  _14,
  _15,
  _16,
  _17,
  _18,
  _19,
  _20,
  _21,
  _22,
  _23,
  _24,
  _25,
  _26,
  _27,
  _28,
  _29,
  _30,
  _31,
  _32,
  _33,
  _34,
  _35,
  _36,
  _37,
  _38,
  _39,
  _40,
  _41,
  _42,
  _43,
  _44,
  _45,
  _46,
  _47,
  _48,
  _49,
  _50,
  _51,
  _52,
  _53,
  _54,
  _55,
  _56,
  _57,
  _58,
  _59,
  _60
}

type data = {
  code: Code;
};

function errorCode(arr: Array<data>, getData: (arr: data) => Code) {
  return pipe(
    arr,
    find((obj) => pipe(obj, getData)), // Type instantiation is excessively deep and possibly infinite.
    (data) => (data !== undefined ? getData(data) : undefined)
  );
}

🙁 Actual behavior

"Type instantiation is excessively deep and possibly infinite" Error occur.

🙂 Expected behavior

No Type Error.


Version Information

  • @fxts/core: 0.21.0
  • Typescript: 5.2.2
@hg-pyun hg-pyun added the bug Something isn't working label Oct 4, 2023
@hg-pyun hg-pyun changed the title "Type instantiation is excessively deep and possibly infinite" error with large enum values. "Type instantiation is excessively deep and possibly infinite" error with large Enum values. Oct 4, 2023
@ppeeou
Copy link
Member

ppeeou commented Mar 19, 2024

@hg-pyun Thank you for reporting the error.
Issue resolved in 0.27.0 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants