score:4

Accepted answer
function nonNullAssert(foo: Foo) {
    console.log(foo.bar!.baz.toUpperCase());
}

nonNullAssert({ bar: { baz: "hello" } }); // HELLO
nonNullAssert({}); // 💥 TypeError: foo.bar is undefined

score:2

const enteredText = textInputRef.current?.value || '';

Related Query

More Query from same tag