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

Type Tweak for the Files Property #1265

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

Conversation

DavidR95
Copy link

When using the flat config in a typechecked ESLint file (with exactOptionalPropertyTypes: true), a type error is reported because the generated type for flat/recommended is a union, where one element in the union contains files?: undefined. As per ESLint's Config type, files can be omitted, but it cannot be explicitly undefined.

This uses a const assertion so that, in the inferred type, files is correctly omitted (or an array of strings).

(https://www.totaltypescript.com/concepts/as-const)

When using the flat config in a typechecked ESLint file (with
`exactOptionalPropertyTypes: true`), a type error is reported
because the generated type for `flat/recommended` is a union, where
one element in the union contains `files?: undefined`. `files` can be
omitted, but it cannot be explicitly `undefined``.

This uses a const assertion so that, in the inferred type, `files` is
correctly omitted.
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.

1 participant