You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
was interpreted to be equivalent to the following JavaScript.
(foo?.bar).baz
In the above code the parentheses stop the “short-circuiting” behavior of optional chaining, so if foo is undefined, accessing baz will cause a runtime error.
@typescript-eslint/no-non-null-asserted-optional-chain made sense in that case but TS 3.9 will change the behavior to this:
foo?.bar.baz
which just evaluates to undefined when foo is undefined.
So foo?.bar!.baz becomes perfectly reasonable to catch an undefined foo but ignore an undefined foo.bar
The text was updated successfully, but these errors were encountered:
From: https://devblogs.microsoft.com/typescript/announcing-typescript-3-9-beta/#breaking-changes
@typescript-eslint/no-non-null-asserted-optional-chain
made sense in that case but TS 3.9 will change the behavior to this:So
foo?.bar!.baz
becomes perfectly reasonable to catch an undefinedfoo
but ignore an undefinedfoo.bar
The text was updated successfully, but these errors were encountered: