Skip to content

fix(eslint-config-fluid): resolve TypeScript errors in flat config types#26424

Open
tylerbutler wants to merge 1 commit intomicrosoft:mainfrom
tylerbutler:fix-ts-errors
Open

fix(eslint-config-fluid): resolve TypeScript errors in flat config types#26424
tylerbutler wants to merge 1 commit intomicrosoft:mainfrom
tylerbutler:fix-ts-errors

Conversation

@tylerbutler
Copy link
Member

@tylerbutler tylerbutler commented Feb 12, 2026

Summary

  • Add type assertions in base.mts for third-party ESLint plugin types (typescript-eslint, import-x, rushstack, eslint-config-prettier) whose .d.ts declarations don't match ESLint 9's updated type interfaces
  • Fix print-configs.ts to accept readonly config arrays from as const exports, removing the need for shallow copies at each call site
  • Fix outputPath possibly-undefined error
  • Remove invalid indentSize option from sortJson call — indentSize only applies to sort-json's file-writing overload, not the in-memory sorting overload used here. Formatting is already handled by JSON.stringify(sortedConfig, null, 4) on the next line, so the option was silently ignored at runtime.

…d print-configs

Fix 13 TS errors across base.mts and print-configs.ts:

base.mts: Add type assertions for third-party ESLint plugin types
(typescript-eslint, import-x, rushstack, prettier) whose .d.ts
declarations don't yet match ESLint 9's updated type interfaces.

print-configs.ts: Accept readonly config arrays from as-const exports,
fix outputPath possibly-undefined, remove invalid sortJson indentSize
option, and remove unused FlatConfigArray type alias.
@tylerbutler tylerbutler marked this pull request as ready for review February 12, 2026 02:16
@tylerbutler tylerbutler requested review from a team and Copilot February 12, 2026 02:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates eslint-config-fluid’s ESLint 9 flat-config tooling to resolve TypeScript type incompatibilities introduced by third-party plugin .d.ts definitions and to improve readonly compatibility in the config printing script.

Changes:

  • Adjust print-configs.ts to accept readonly flat config arrays and fix a possibly-undefined outputPath.
  • Add targeted type assertions in base.mts for third-party plugin/config exports whose declared types don’t match ESLint 9’s interfaces.
  • Remove the invalid indentSize option from the in-memory sort-json call.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
common/build/eslint-config-fluid/scripts/print-configs.ts Accepts readonly config arrays and fixes TS errors around overrideConfig and outputPath.
common/build/eslint-config-fluid/library/configs/base.mts Adds type assertions for plugin/config exports to align with ESLint 9 flat-config typings.

Copy link
Contributor

@alexvy86 alexvy86 left a comment

Choose a reason for hiding this comment

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

One small thing below. I think it would be nice to have references to existing open issues in the new comments but I could not find any. Oh well.

},
// Prettier disables conflicting rules - must come after custom rules
prettierConfig,
prettierConfig as Linter.Config,
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comment like the ones above?

Copy link
Contributor

Choose a reason for hiding this comment

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

Should be able to just remove this cast similar to removing tseslint.configs.* casts.

Comment on lines +62 to +65
// Type assertions needed: typescript-eslint's PluginFlatConfig.languageOptions lacks the
// string index signature that ESLint core's LanguageOptions requires.
...(tseslint.configs.recommendedTypeChecked as Linter.Config[]),
...(tseslint.configs.stylisticTypeChecked as Linter.Config[]),
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you certain erasing the specific types from these are correct? I have a strong feeling that issue can be resolved without these casts. We should limit as as much as possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you have something specific in mind?

Copy link
Contributor

Choose a reason for hiding this comment

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

I looked at the error and I am confused. When I try to inspect things VS Code says that the type of these are

{
    name?: string;
    rules?: object;
}[]

The visible error shown is a complaint about LanguageOptions. That doesn't add up.
If you remove the other entries following those, then there isn't a complaint. I narrowed it down to lines 65, 66, and 72 as contributing to the problem.
If you comment those out, then there is no error.
You can see that importXPlugin is more of the issue. Temporarily adding:

const X = tseslint.configs.recommendedTypeChecked satisfies Linter.Config[];
const Y = importXPlugin.flatConfigs.recommended satisfies Linter.Config;

will show that importXPlugin does not satisfy Linter.Config, which you already know as those lines have been changed.
I think TypeScript error is bad (bug) and these casts can be removed. You can use satisfies in place of as on these lines. Then the comment for casting moves down to importXPlugin that is a real problem.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the reminder of satisfies. I keep forgetting about it.

Copy link
Contributor

@jason-ha jason-ha left a comment

Choose a reason for hiding this comment

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

Putting a light block here - see prior questions

Comment on lines -29 to +31
type FlatConfigArray = Linter.Config[];

interface ConfigToPrint {
name: string;
config: FlatConfigArray;
config: readonly Linter.Config[];
Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively import FlatConfigArray from base.mts definition? That definition also makes Linter.Config readonly (= readonly Readonly<Linter.Config>[])

@jason-ha jason-ha dismissed their stale review February 12, 2026 19:17

Conversation acknowledged - hard block no longer required

@jason-ha
Copy link
Contributor

While here print-configs.ts's configsToPrint is better set as

const configsToPrint = [
 ...
] as const satisfies readonly ConfigToPrint[];

since it is a constant.

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.

3 participants