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
declareletobj: {prop: string|null}|undefined;leta=obj?.prop!;// not allowed: 'a' is inferred as 'string' instead of 'string | undefined'letb=obj?.prop!.length;// allowed to asssert that a certain property in the chain is not nullish, 'b' is 'number | undefined' as expected
NonNull inside an optional chain is treated special and only asserts that one element in the chain is non-null. Whereas NonNull at the end of an optional chain removes null and undefined from the type of the whole chain. That doesn't make any sense because you wouldn't need an optional chain if you knew everything is non-null.
The text was updated successfully, but these errors were encountered:
NonNull inside an optional chain is treated special and only asserts that one element in the chain is non-null. Whereas NonNull at the end of an optional chain removes null and undefined from the type of the whole chain. That doesn't make any sense because you wouldn't need an optional chain if you knew everything is non-null.
The text was updated successfully, but these errors were encountered: