-
-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Description
Trying to configure eslint-plugin-prefer-arrow-functions
in a eslint.config.ts
file results in Type issues for meta
being possibly undefined
.
47:7 error Type '{ meta: { name?: string | undefined; version?: string | undefined; } | undefined; rules: Record<string, LooseRuleDefinition> | undefined; }' is not assignable to type 'Omit<Plugin, "configs">' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. typescript(2375)
Types of property 'meta' are incompatible.
Type '{ name?: string | undefined; version?: string | undefined; } | undefined' is not assignable to type '{ name?: string | undefined; version?: string | undefined; }'.
Type 'undefined' is not assignable to type '{ name?: string | undefined; version?: string | undefined; }'.
This is what the current index.d.ts
file says:
import { TSESLint } from '@typescript-eslint/utils';
export declare const meta: {
name?: string | undefined;
version?: string | undefined;
} | undefined, rules: Record<string, TSESLint.LooseRuleDefinition> | undefined;
Using eslint version:
$ npx eslint --version
v9.21.0
and latest version of this plugin.
Work Around
import { meta, rules } from 'eslint-plugin-prefer-arrow-functions';
// Should never happen, but tsc doesn't know that.
if (meta == undefined) {
throw new Error('eslint-plugin-prefer-arrow-functions.meta is undefined');
}
export default tseslint.config(
{
plugins: {
preferArrow: { meta, rules },
elliotleelewis
Metadata
Metadata
Assignees
Labels
No labels