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

fix: Update types.ts for compatibility with verbatimModuleSyntax #88

Merged
merged 3 commits into from
Mar 24, 2025

Conversation

mrmckeb
Copy link
Contributor

@mrmckeb mrmckeb commented Mar 19, 2025

Prerequisites checklist

What is the purpose of this pull request?

After using this package in with the new verbatimModuleSyntax TypeScript compiler option, I hit the below error.

error TS1484: 'ElementNode' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.
error TS1484: 'ObjectNode' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled.
...

What changes did you make? (Give an overview)

Changed to a type-only import for imports from @humanwhocodes/momoa.

Related Issues

Related to #84.

Is there anything you'd like reviewers to focus on?

Only one line changed.

Sorry, something went wrong.

@mrmckeb
Copy link
Contributor Author

mrmckeb commented Mar 19, 2025

I verified this locally with pnpm patch [package], where the diff was:

diff --git a/dist/esm/types.ts b/dist/esm/types.ts
index f8dc7e1bee1a342e233c513d142aec97e08c6369..577f2229bb2d64db4868d482cb79586f350f59a1 100644
--- a/dist/esm/types.ts
+++ b/dist/esm/types.ts
@@ -14,7 +14,7 @@ import type {
 	LanguageOptions,
 	RuleDefinition,
 } from "@eslint/core";
-import {
+import type {
 	DocumentNode,
 	MemberNode,
 	ElementNode,

@nzakas
Copy link
Member

nzakas commented Mar 20, 2025

Thanks for looking into this. It would be helpful to have a test to run in CI to validate this change. Is it possible to update typedefs.test.ts for this purpose? Or could we create a separate that is similar?

@mrmckeb
Copy link
Contributor Author

mrmckeb commented Mar 21, 2025

Thanks @nzakas, I've just added a pass/fail test for one of the affected types. Please let me know if that's not what you had in mind though!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to add "verbatimModuleSyntax": true to tests/types/tsconfig.json, otherwise the new test will pass even if the change in the source file is reverted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated!

@fasttime fasttime changed the title feat: Update types.ts for compatibility with verbatimModuleSyntax fix: Update types.ts for compatibility with verbatimModuleSyntax Mar 24, 2025
@eslint-github-bot eslint-github-bot bot added the bug Something isn't working label Mar 24, 2025
@fasttime
Copy link
Member

Note: I've changed the tag in the PR title to "fix:" because this change fixes a bug.

@fasttime fasttime removed the feature label Mar 24, 2025
@fasttime
Copy link
Member

LGTM, thanks! Leaving open for @nzakas to verify.

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@nzakas nzakas merged commit d099c78 into eslint:main Mar 24, 2025
16 checks passed
@mrmckeb mrmckeb deleted the patch-1 branch March 25, 2025 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted bug Something isn't working contributor pool
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

None yet

3 participants