Reputation: 190
I'm creating this React hook, which exposes a user object. Inside the hook I'm defining the type as either 'CognitoUserInterface | undefined'. Since the object will be undefined during initialization.
When I use this hook inside a component, VS code does not warn me that the object will possibly be undefined. I've created an example in CodeSandbox which does however warn. Both use the same code, and same version of TypeScript.
Is this some bug in VS Code? I already tried restarting the TypeScript server. What else could be going on?
Upvotes: 0
Views: 1147
Reputation: 190
Based on the comment by Mohammad I saw 'strict' mode was false in my VSCode environment. Enabling this fixed my issue :)
Upvotes: 3