G
G
GaserV2019-11-24 18:02:44
typescript
GaserV, 2019-11-24 18:02:44

How to explain to the typescript that children will be rendered only if the condition passes?

There is a helper component that will render children only if the passed condition is true. There is a component, say UserProfile , that accepts the required user prop. And when I put this profile component inside my helper, the TS says that the object can be empty, but in the component it should not be empty. And if you use an ordinary ternark, then everything is fine. Is there any way to tell the TS that this component won't render it without data to avoid this TS error?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
abberati, 2019-11-24
@abberati

Without code examples, the only thing that can be said is go learn typescript.

P
Pavel Didenko, 2019-11-25
@Dasslier

Here

I
IDONTSUDO, 2019-11-25
@IDONTSUDO

data type: any

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question