I have come across an issue regarding type error reporting when handling a function parameter:
private _toggle(updates: I_Type | null) {
const should_toggle = this.thing && !updates.foo
// ...
}
The variable updates
is supposed to be of type I_Type
or null
. However, there seems to be a lack of type errors being displayed when accessing !updates.foo
without using optional chaining. In other words, the absence of a type error only occurs if we use the ?.
operator like so: !updates?.foo
.
I am unsure if I am misunderstanding something, or if my eslint/tslint configuration is incorrect. Shouldn't !updates.foo
trigger a type error?
Update
In response to VLAZ's comment, the suggested solution is to include strict
in the tsconfig under compilerOptions
.