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

feat: Add types to exports #84

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat: Add types to exports #84

wants to merge 1 commit into from

Conversation

mrmckeb
Copy link

@mrmckeb mrmckeb commented Mar 3, 2025

Prerequisites checklist

What is the purpose of this pull request?

Enables users to import additional types.

What changes did you make? (Give an overview)

This PR adds the types file to package.json#exports, allowing users to import types not exposed via the index files from the /types export.

import type { JSONRuleDefinition } from "@eslint/json/types";

Related Issues

Closes #82

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

N/A

@eslint-github-bot
Copy link

Hi @mrmckeb!, thanks for the Pull Request

The pull request title isn't properly formatted. We ask that you update the pull request title to match this format, as we use it to generate changelogs and automate releases.

  • The commit message tag wasn't recognized. Did you mean "docs", "fix", or "feat"?
  • There should be a space following the initial tag and colon, for example 'feat: Message'.
  • The first letter of the tag should be in lowercase

To Fix: You can fix this problem by clicking 'Edit' next to the pull request title at the top of this page.

Read more about contributing to ESLint here

Copy link

linux-foundation-easycla bot commented Mar 3, 2025

CLA Signed


The committers listed above are authorized under a signed CLA.

@mrmckeb mrmckeb changed the title Add types to exports feat: Add types to exports Mar 3, 2025
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.

Thanks. Can you also add some tests to verify that this works as expected? (tests/types/types.test.ts)

@eslint/eslint-tsc Wanted to verify with everyone that we're okay with exporting types this way? Or should we aim to export types from . (which would require a bit of scripting).

@mrmckeb
Copy link
Author

mrmckeb commented Mar 3, 2025

Thanks for the prompt review and feedback @nzakas. I'll wait for the response around exporting types this way, and then either rework this PR or update the tests.

@mdjermanovic
Copy link
Member

Wanted to verify with everyone that we're okay with exporting types this way?

I'm fine with this approach. @fasttime what do you think?

@fasttime
Copy link
Member

fasttime commented Mar 6, 2025

I'm also fine with this approach. Note though that we need a separate export for CommonJS types, along the lines of:

"./types": {
  "require": {
    "types": "./dist/cjs/types.cts"
  },
  "import": {
    "types": "./dist/esm/types.d.ts"
  }
}

This is to avoid the TypeScript error Type-only import of an ECMAScript module from a CommonJS module must have a 'resolution-mode' attribute.

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

Successfully merging this pull request may close these issues.

Change Request: Export JSONRuleDefinition and other types
4 participants