Skip to content

ForbidItemObject type broken #23732

Description

@Mister-Hope
  × typescript(TS2322): Type '{ propName: string; allowedFor: [string, string, string, string]; allowedForPatterns: [string]; }' is not assignable to type 'ForbidItem'.
    ╭─[oxlint.config.ts:20:13]
 19 │               forbid: [
 20 │ ╭─▶             {
 21 │ │                 propName: "className",
 22 │ │                 allowedFor: ["AdaptiveImage", "Icon", "Iconify", "RichContent"],
 23 │ │                 allowedForPatterns: ["**Tag"],
 24 │ ╰─▶             },
 25 │                 { propName: "style", allowedFor: ["Iconify"], allowedForPatterns: ["**Tag"] },
    ╰────

  × typescript(TS2322): Type '{ propName: string; allowedFor: [string]; allowedForPatterns: [string]; }' is not assignable to type 'ForbidItem'.
    ╭─[oxlint.config.ts:25:13]
 24 │             },
 25 │             { propName: "style", allowedFor: ["Iconify"], allowedForPatterns: ["**Tag"] },
    ·             ─────────────────────────────────────────────────────────────────────────────
 26 │           ],
    ╰────

Found 22 warnings and 2 errors.
Finished in 337ms on 45 files with 578 rules using 10 threads.
[ELIFECYCLE] Command failed with exit code 1.

However, the usage is correct. ForbidItemObject requires all allowed/disallowed fields by mistake:

interface ForbidItemObject {
  /**
   * Component names for which this prop is **allowed** (all others are
   * forbidden).
   */
  allowedFor: string[];
  /**
   * Glob patterns for component names where the prop is **allowed**.
   */
  allowedForPatterns: string[];
  /**
   * Component names for which this prop is **disallowed** (all others are
   * allowed).
   */
  disallowedFor: string[];
  /**
   * Glob patterns for component names where the prop is **disallowed**.
   */
  disallowedForPatterns: string[];
  /**
   * Custom message to display.
   */
  message?: string;
  /**
   * Exact prop name to forbid.
   */
  propName?: string;
  /**
   * Glob pattern to match prop names against.
   */
  propNamePattern?: string;
}

1-4 allowed/disallowed field shall all be considered as legal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions