Skip to content

Bug: Functions are exported as type-only from commonjs export of @eslint/config-helpers #425

@youngspe

Description

@youngspe

Which packages are affected?

  • @eslint/compat
  • @eslint/config-array
  • @eslint/config-helpers
  • @eslint/core
  • @eslint/mcp
  • @eslint/migrate-config
  • @eslint/object-schema
  • @eslint/plugin-kit

Environment

Node version: v23.10.0
npm version: 10.9.2
ESLint version: 10.2.0
Operating System: Ubuntu 24.04.4 LTS (through WSL)

What did you do?

My code was importing and calling defineConfig from 'eslint/config':

// eslint.config.mjs

import { defineConfig } from 'eslint/config';

defineConfig(/* ... */);

What did you expect to happen?

Ideally, this would type check without any errors.

What actually happened?

@typescript/native-preview gives the following error:

eslint.config.cjs:3:1 - error TS1361: 'defineConfig' cannot be used as a value because it was imported using 'import type'.                    
                                                                                                                                               
3 defineConfig(/* ... */);                                                                                                                              
  ~~~~~~~~~~~~                                                                                                                                 
                                                                                                                                               
  node_modules/@eslint/config-helpers/dist/cjs/index.d.cts:1:18 - 'defineConfig' was imported here.                                            
    1 import type * as types from "../esm/index.js" with { "resolution-mode": "import" };        

Link to Minimal Reproducible Example

https://github.com/youngspe/eslint-types-example

Participation

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

AI acknowledgment

  • I did not use AI to generate this issue report.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

Additional comments

Looks like this was introduced by #416

@eslint/config-helpers/dist/cjs/index.d.cjs looks like this as of @eslint/config-helpers@0.5.2:

import type * as types from "../esm/index.js" with { "resolution-mode": "import" };
export = types;

Since the functions defineConfig and globalIgnores are imported through import types before being re-exported, they're techincally type-only exports.

This causes build errors with @typescript/native-preview@^7.0.0-dev.20260404.1 when calling those functions, either directly through '@eslint/config-helpers' from a commonjs module or through 'eslint/config' from any module. Curiously, typescript@6.0.2 is not reporting errors, though as far as I can tell it should because it's still a re-export of a type-only import.

This likely applies to other packages changed by #416 but I haven't checked that.

Feel free to close if this is a won't-fix because it only fails on a pre-production TypeScript compiler version.

Metadata

Metadata

Assignees

Labels

acceptedbugSomething isn't workingrepro:yesIssues with a reproducible example

Type

No type

Projects

Status

Ready to Implement

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions