The below code is producing a type error which i am not able to solve, Any suggestion would be helpful, I am fairly new to typescript.
1) File name Model.ts which holds below code
export declare namespace player {
enum status {
HOLD = "hold".
PLAYING = "playing",
}
}
export interface player {
id? : String;
playerName? : String;
joiningDate? : number;
status : player.status
}
2) Receiving following JSON data via API call
{
"status" : "success",
"validations" : null,
"data" : {
id? : "scbgfd-23432-kudgba";
playerName? : 'Jhon Doe';
joiningDate? : 164952142565;
status : 'hold'
}
}
3) Business Logic
export const filterPlayer = (data : Player) : string => {
/// Logic For Filtering Player and Returning its ID
}
const player = // Api Call Receiving Above JSON Data //
const filteredPlayer = filterPlayer(player) // This line Produce Error
The Error Produced By Above Mentioned Line
Argument Of Type {
id? : String;
playerName? : String;
joiningDate? : number;
status : player.status
} is not assignable to parameter of type "Player".
Types of property status are incompatible.
Type String is not assignable to type "Status | undefined".
What can i pass in the JSON so that the Lint and Test case both doesn’t throw an error !!