Does TypeScript have a Null-conditional operator

前端 未结 6 1286
误落风尘
误落风尘 2020-12-11 00:10

Is there any operator like ?. in TypeScript that can check if the variable is null or not defined like Kotlin? Like

person?.getName()?.firstName ?: \"None\"
         


        
6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-11 00:19

    Actually this is related to javascript null safety discussion that is mentioned in this answer. I guess they want it to be supported on javascript before they will get to typescript.

提交回复
热议问题