All optional properties and parameters should be of type Maybe<T>
.
This rule aims to ensure that we don't treat null
and undefined
differently.
Autofixer available.
Examples of incorrect code for this rule:
interface x {
y?: string;
}
function f(x?: number) {}
Examples of correct code for this rule:
interface x {
y?: Maybe<string>;
}
function f(x?: Maybe<number>) {}
With third-party software that needs to differentiate between null
and undefined
.