The error is legitimate and may prevent your app from crashing. You typed makes
as an array but it can also be undefined.
You have 2 options (instead of disabling the typescript's reason for existing...):
1. In your case the best is to type makes
as possibily undefined.
makes?: any[]
// or
makes: any[] | undefined
In this case the compiler will inform you whenever you try to access to makes
that it could be undefined.
For exemple if the // <-- Not ok
lines below are executed before getMakes
finished or if getMakes
fails, your app will crash and a runetime error will be thrown.
makes[0] // <-- Not ok
makes.map(...) // <-- Not ok
if (makes) makes[0] // <-- Ok
makes?.[0] // <-- Ok
(makes ?? []).map(...) // <-- Ok
2. You can assume that it will never fail and that you will never try to access it before initialization by writing the code below (risky!). So the compiler won't take care about it.
makes!: any[]