Object is possibly 'undefined'
See original GitHub issueHi!
I’m using TypeScript 3.0.3 and while using your plugins it’s pretty annoying because I need to wrap them inside “if/else” statements to avoid this error;
Object is possibly 'undefined'
Here an example of my code:
import { Plugins, StatusBarStyle } from '@capacitor/core';
const { StatusBar } = Plugins;
StatusBar.setStyle({
style: StatusBarStyle.Dark
});
Note: the error is for the StatusBar.setStyle
How do you manage that? Seems really repetitive to write if/else each time I need to use these plugins 😢
Thank you,
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How can I solve the error 'TS2532: Object is possibly ...
Typescript is saying that change or data is possibly undefined (depending on what onUpdate returns). So you should wrap it in a null/undefined...
Read more >Object is possibly 'undefined' error in TypeScript | bobbyhadz
The "Object is possibly 'undefined'" error occurs when we try to access a property on an object that may be undefined (e.g. marked...
Read more >[Solved] Object is possibly 'undefined' error in TypeScript
The Object is possibly 'undefined' occurs when we try to access a property of an object that is undefined . Sometimes few properties...
Read more >How to solve 'Object is possibly undefined' error in TypeScript?
Let's understand why the error occurs. The reason for the error is, that while declaring the employee1 object, we are passing only the...
Read more >How to solve TypeScript possibly undefined value
This article goes over 5 methods to solve a problem like TS2532: Object is possibly 'undefined'. You can use IF conditions, logical operator ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @simonhaenisch! closing
This has been fixed by #1507.