Skip to content

TypeaheadField constructor description parameter is required, should be optional (TS2345) #120

@paperboyo

Description

@paperboyo

Hi. Sorry, my helpful robot insists it found something. I obviously don't have a clue. Please excuse me and close if it's shrooms...

Severity: Medium — forces callers to pass dummy values.

Error:

Argument of type 'undefined' is not assignable to parameter of type 'string'.

at new TypeaheadField(id, name, undefined, resolver, "TEXT") — the third argument (description) is typed as string but many callers don't have a description.

Current declaration:

constructor(
  id: string,
  name: string,
  description: string,            // ← required
  resolver?: TypeaheadResolver | undefined,
  suggestionType?: SuggestionType
);

Proposed fix:
Make description optional with a default:

constructor(
  id: string,
  name: string,
  description?: string,           // ← optional
  resolver?: TypeaheadResolver | undefined,
  suggestionType?: SuggestionType
);

or, if changing the positional API is undesirable, accept string | undefined:

constructor(
  id: string,
  name: string,
  description: string | undefined,
  resolver?: TypeaheadResolver | undefined,
  suggestionType?: SuggestionType
);

and default to "" in the body:

this.description = description ?? "";

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions