preferOptionalParameterParameter `{{parameter}}` includes `undefined` in its type. Declare it optional with `?` instead.small-rules/prefer-optional-parameterDisallow `undefined` in a function parameter's type union; declare the parameter optional with `?` instead.
scenario?: ScenarioId and scenario: ScenarioId | undefined accept the same values. The first one lets
the caller omit the argument. The second one still requires an argument, so the callee must handle
undefined. The caller cannot tell whether the parameter is optional or whether undefined is a real
value.
A default value and a rest parameter are already optional. The rule leaves them alone. It also leaves a
parameter alone where ? is invalid. An optional parameter cannot come before a required one. An accessor
setter cannot be optional. A destructuring parameter can only be optional in a declaration signature, not in
a function with a body. In those positions the union is the only valid way to accept undefined, so the
rule doesn’t report.
preferOptionalParameterParameter `{{parameter}}` includes `undefined` in its type. Declare it optional with `?` instead.This rule does not accept options.
function getOpeningTurns(scenario: ScenarioId | undefined): ReadonlyArray<ShownTurn> {}After auto-fix
function getOpeningTurns(scenario?: ScenarioId): ReadonlyArray<ShownTurn> {}function getOpeningTurns(scenario?: ScenarioId): ReadonlyArray<ShownTurn> {}