type example = {
name : string | number | null
}
type processNumber = {
name : number
}
const a : example = {
name : 123
} as const
function PROCESS (input : processNumber) {
console.log(input.name)
}
PROCESS(a);
I am facing an issue where the error message states:
Argument of type 'example' is not assignable to parameter of type 'processNumber'.
Types of property 'name' are incompatible.
Type 'string | number | null' is not assignable to type 'number'.
Type 'null' is not assignable to type 'number'.
How can I convert name
to be strictly of type number
? It should be noted that there are multiple properties that require coercion, so any quick and inline method for coercion would be greatly appreciated.