Skip to content

prefer-immutable-types causes ESLint to crash on matrices #875

@Tim-W-James

Description

@Tim-W-James
const myFunction = (x: number[][]): string => {
  return 0;
};

Causes the rule to crash:

Oops! Something went wrong! :(

ESLint: 8.56.0

RangeError: Maximum call stack size exceeded
Occurred while linting .../src/index.ts:1
Rule: "functional/prefer-immutable-types"
    at TypeObject.hasOwn (<anonymous>)
    at Function.hasOwn (<anonymous>)
    at isTypeNode (.../is-immutable-type/dist/index.cjs:287:19)
    at .../is-immutable-type/dist/index.cjs:246:30
    at Array.map (<anonymous>)
    at typeArgumentsToString (.../is-immutable-type/dist/index.cjs:245:47)
    at TypeName.getNameWithArguments (.../is-immutable-type/dist/index.cjs:171:54)
    at .../is-immutable-type/dist/index.cjs:253:26
    at Array.map (<anonymous>)
    at typeArgumentsToString (.../node_modules/is-immutable-type/dist/index.cjs:245:47)

While it doesn't crash with a single-depth array number[]

const myFunction = (x: number[]): string => {
  return 0;
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions