Problem:
Since setters of model allow for number or string, providing type safety to declarations must be ensured when getting the model by specfically stating player.model as number every time.
Example:
const map = new Map<number, any>(); // Maps player model hash to something
if (map.has(p.model)) {} // Will throw "Argument of type 'string | number' is not assignable to parameter of type 'number'.
Type 'string' is not assignable to type 'number'.ts(2345)" and must be circumvented by:
if (map.has(p.model as number)) {}
…getter for vehicle
Problem: Since setters of model allow for number or string, providing type safety to declarations must be ensured when getting the model by specfically stating
player.model as number
every time.Example:
Getter and setter approach resolves this issue.