eslint-plugin-functional icon indicating copy to clipboard operation
eslint-plugin-functional copied to clipboard

type-declaration-immutability: RangeError: Maximum call stack size exceeded

Open cs4inctec opened this issue 1 year ago • 1 comments

Bug Report

while updating from v5 to v6, rule type-declaration-immutability now throws an error RangeError: Maximum call stack size exceeded

looks similar to https://github.com/eslint-functional/eslint-plugin-functional/issues/733

Expected behavior

eslint terminates

Actual behavior

throws error

ESLint: 8.56.0

RangeError: Maximum call stack size exceeded
Occurred while linting /home/jenkins_home/workspace/ing-services_Lint_eslint-updates/accounts-wrapper/users/types.ts:26
Rule: "functional/type-declaration-immutability"
    at Object.isIntrinsicErrorType (/home/jenkins_home/workspace/ing-services_Lint_eslint-updates/node_modules/ts-api-utils/lib/index.cjs:140:25)
    at Object.get [as isIntrinsicErrorType] (/home/jenkins_home/workspace/ing-services_Lint_eslint-updates/node_modules/ts-api-utils/lib/index.cjs:16:45)
    at getTypeData (/home/jenkins_home/workspace/ing-services_Lint_eslint-updates/node_modules/is-immutable-type/dist/index.cjs:301:20)
    at /home/jenkins_home/workspace/ing-services_Lint_eslint-updates/node_modules/is-immutable-type/dist/index.cjs:248:15
    at Array.map (<anonymous>)
    at typeArgumentsToString (/home/jenkins_home/workspace/ing-services_Lint_eslint-updates/node_modules/is-immutable-type/dist/index.cjs:245:47)
    at TypeName.getNameWithArguments (/home/jenkins_home/workspace/ing-services_Lint_eslint-updates/node_modules/is-immutable-type/dist/index.cjs:171:54)
    at /home/jenkins_home/workspace/ing-services_Lint_eslint-updates/node_modules/is-immutable-type/dist/index.cjs:253:26
    at Array.map (<anonymous>)
    at typeArgumentsToString (/home/jenkins_home/workspace/ing-services_Lint_eslint-updates/node_modules/is-immutable-type/dist/index.cjs:245:47)
script returned exit code 2

Steps to reproduce

Proposed changes

cs4inctec avatar Jan 22 '24 17:01 cs4inctec

It doesn't like React.ComponentProps<typeof SomeComponent> either

dacevedo12 avatar Feb 18 '24 05:02 dacevedo12

I'm facing this as well.

griffin-ezbot avatar Mar 15 '24 18:03 griffin-ezbot

:tada: This issue has been resolved in version 6.2.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Mar 22 '24 11:03 github-actions[bot]

I've removed 2 infinite loops I've found in the upstream, hopefully, that fixes the issue for everyone. If you're still getting this error, let me know; and if you can include a type that causes the issue.

RebeccaStevens avatar Mar 22 '24 11:03 RebeccaStevens

@RebeccaStevens I still hit one case where I am using forwardRef with ComponentProps in react

Example:

type Props = Readonly<JSX.IntrinsicElements['input']>
const Input = forwardRef<HTMLInputElement, Props>(
  function InnerInput(props, ref) {
    return <input {...props} ref={ref} />
  },
)

type PropsB = Readonly<ComponentProps<typeof Input>> // This line throws `RangeError: Maximum call stack size exceeded`

foray1010 avatar Mar 29 '24 04:03 foray1010

@foray1010 I haven't explicitly tried to fix this again yet, but I have made some updates that might have consequently fixed the issue. Let me know if you are still getting this issue with the latest release.

RebeccaStevens avatar Apr 15 '24 14:04 RebeccaStevens

@RebeccaStevens I can confirm the above issue has been fixed in 6.5.1, thank you!

foray1010 avatar Apr 15 '24 14:04 foray1010

That's good to hear. I'll close this issue.

RebeccaStevens avatar Apr 16 '24 00:04 RebeccaStevens