Accept any type that satisifies that other type in function

Is there like
type AWithFields = {
foo: string
}

const mapper = <T satisifies AWithFields>(param: T) => {
// update param fields here and return
return param
}
type AWithFields = {
foo: string
}

const mapper = <T satisifies AWithFields>(param: T) => {
// update param fields here and return
return param
}
I wanted to accept any param that satisifies AWithFields in the function.
1 Reply
Chooβ™šπ•‚π•šπ•Ÿπ•˜
const mapper = <T extends AWithFields>(param: T) => {
// update param fields here and return
return param
}
const mapper = <T extends AWithFields>(param: T) => {
// update param fields here and return
return param
}
Want results from more Discord servers?
Add your server