no-inferrable-types
What it does
Section titled “What it does”Reports a type annotation on a variable, parameter or class property whose initial value already gives that type (const a: number = 5, s: string = 'x', b: boolean = true, n: bigint = 1n). A value from a call, a readonly property and an optional property are not reported.
Why it matters
Section titled “Why it matters”The compiler infers the same type from the value, so the annotation only adds a second place to keep in sync.
To fix, drop the annotation.
Example
Section titled “Example”let a: "a" = "a", b: "a" = 'a', c: 1 = 1, d: string = "a";...Configuration
Section titled “Configuration”js: lint: rules: no-inferrable-types: warn # off (default), warn, errorSuppress one line with sudsy-disable-next-line no-inferrable-types in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| typescript-eslint | no-inferrable-types |
partial | the options (ignoreParameters, ignoreProperties) keep their defaults |