目录

@typescript-eslint/prefer-reduce-type-parameter

Enforce using type parameters when calling Array#reduce instead of type assertions.

Rule Configuration

// code-linter.json5
{
  "rules": {
    "@typescript-eslint/prefer-reduce-type-parameter": "error"
  }
}

Options

This rule is not configurable.

Example of Correct Code

['1', '2', '3'].reduce<readonly string[]>((arr, text) => {
  const newArr = [...arr];
  newArr.push(text);
  return newArr;
}, []);

Example of Incorrect Code

['1', '2', '3'].reduce((arr, text) => {
  const newArr = [...arr];
  newArr.push(text);
  return newArr;
}, [] as readonly string[]);

Rule Set

plugin:@typescript-eslint/all

For details about how to configure Code Linter check rules, see Code Linter.