Added type inference for optional chaining