Skip to content

Fix: Improve type safety in features/support/formatter_output_helpers, removes explicit any #1648 #2558

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

micmath
Copy link

@micmath micmath commented May 12, 2025

🤔 What's changed?

Modified several places where ESLint was complaining about the use of explicit any ( after I set @typescript-eslint/no-explicit-any to 2) in the features/support/formatter_output_helpers.ts file.

There were multiple checks using doesHaveValue but unfortunately this does not assure the TypeScript compiler that it is safe to refer to properties of the value; e.g. let x = 2; if (doesHaveValue(x)) console.log(x.anything) // type error so I had to add a isObject check so that it would be safe to refer to properties of values. So the use of doesHaveValue was replaced by isObject in a few places. You may want to move the isObject function to a shared file like src/value_checker because it's not specifically tied to the file it is defined in.

In other places I just replaced any with the correct type.

⚡️ What's your motivation?

This will improve the type safety of the code base a tiny bit and help whittle down the list of files that break when the @typescript-eslint/no-explicit-any rule is enabled.

🏷️ What kind of change is this?

  • 🏦 Refactoring/debt/DX (improvement to code design, tooling, etc. without changing behaviour)

♻️ Anything particular you want feedback on?

There are multiple ways that this issue could have been resolved; I tried to pick a solution that made the least changes to the existing code. You may have different priorities.

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

This text was originally generated from a template, then edited by hand. You can modify the template here.

@coveralls
Copy link

Coverage Status

coverage: 97.736%. remained the same
when pulling d872898 on micmath:issue-1648
into ff894c1 on cucumber:main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants