Closed 0x30 closed 4 years ago
foo.foo?.name = "hello"
Optional assignment is discussed in https://github.com/tc39/proposal-optional-chaining/issues/18.
if let foo1 = foo?.foo { … }
See https://github.com/tc39/proposal-Declarations-in-Conditionals
foo.foo?.name = "hello"
Optional assignment is discussed in #18.
if let foo1 = foo?.foo { … }
See https://github.com/tc39/proposal-Declarations-in-Conditionals
@jridgewell ok. thanks. I went to have a look. The proposal is already very good
Closing this issue per https://github.com/tc39/proposal-optional-chaining/issues/126#issuecomment-551361926 above.
TypeScript - issues 34970
I think I should bring it up here
Search Terms
Suggestion
if let
style,determine whether it is optional and obtain the objectUse Cases
for Suggestion 1
The following code is not allowed in
typescript 3.7.2
.It's going to make aThe left-hand side of an assignment expression may not be an optional property access
mistakeBut similar code, swift works well
In view of this, do we have any plans to solve this problem at present?
for Suggestion 2
About judging optional variables and using it,The current practice of TS is
In swift, there is a way to turn optional into non optional.
Can be used in 'kotlin'
If you judge a method result. In order not to call the calculation twice, you need to replace the code with.