optional chaining and type casting