QuizNot attempted
Which narrowings work?
1–4 to choose, Enter to submit
Show answer & explanation
Correct answers:
typeof x === 'string'x instanceof Datetypeof x === 'object' && x !== null && 'kind' in x
typeof x === 'string',x instanceof Date, and thetypeof ... 'object'+!== null+'kind' in xchain are all control-flow narrowings TS understands.- Not x as Date: an assertion overrides the type for that expression with no runtime check, it never narrows
xitself.