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

Change Request: add type tests #61

Closed
1 task done
fasttime opened this issue Nov 20, 2024 · 1 comment · Fixed by #65
Closed
1 task done

Change Request: add type tests #61

fasttime opened this issue Nov 20, 2024 · 1 comment · Fixed by #65
Assignees
Labels
accepted enhancement New feature or request

Comments

@fasttime
Copy link
Member

Environment

ESLint version: v9.15.0
@eslint/json version: v9.15.0
Node version: v23.2.0
npm version: 10.9.0
Operating System: Windows

What problem do you want to solve?

The types for this plugin are generated automatically using TypeScript's type inference because there is no explicit JSDoc type annotation for the main export. Type inference relies on several assumptions to work correctly and can easily break if the code is changed or refactored, but with the current setup, a breakage in the types would go unnoticed.

What do you think is the correct solution?

There should be unit tests for the types.

Participation

  • I am willing to submit a pull request for this change.

Additional comments

An example of incorrect types that was noticed in #59 is the case in which a nested property is assigned a value after the plugin object is declared. The naive assignment using plugin.configs.recommended.plugins.json = plugin; would cause TypeScript to discard part of the type information from the previous declaration and end up with an incomplete type in the generated .d.ts files.

@fasttime fasttime added the enhancement New feature or request label Nov 20, 2024
@nzakas
Copy link
Member

nzakas commented Nov 20, 2024

Makes sense to me 👍

@nzakas nzakas added this to Triage Nov 20, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Nov 20, 2024
@nzakas nzakas moved this from Needs Triage to Ready to Implement in Triage Nov 20, 2024
@fasttime fasttime mentioned this issue Nov 21, 2024
1 task
@github-project-automation github-project-automation bot moved this from Ready to Implement to Complete in Triage Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted enhancement New feature or request
Projects
Status: Complete
Development

Successfully merging a pull request may close this issue.

2 participants