VS Code comes with inbuilt TypeScript intelligence. TypeScript is telling us that event.target could be null — not based on our code, but on the definitions themselves. It is possible for the Event’s target property to be null (for example, a directly created Event object with no target given) This works in the browser and all is well.