I'm new to typescript, with the following code interface definition.
export Interface Response { content?: { // ... } } let response: Response | null = something();
How to access content without doing null checks, which i assume is not at all the best approach.
if (response != null) { if (response.content != null) { content = (response.content as MyContent); } }
content = response?.content == null ? null : response.content as MyContent;
2.1m questions
2.1m answers
60 comments
56.9k users