Reputation: 1
type T0 = {
a: string
b: string
}
type T1 = Omit<T0, 'b'>
function func({ param }: { param: T0 | T1 }) {
if (param.hasOwnProperty('b')) { /* reassign type */ }
return param.b
}
Is there a possibility to reassign type for param
from T0 | T1
to T0
?
Upvotes: 0
Views: 40
Reputation: 131
I believe you should just put optional b and use just one type
type T0 = {a:string, b:?string }
Upvotes: 1