2 ms·
FWIW, you can achieve row polymorphism in TypeScript, although it's not super intuitive. function rowPolymorphic<R extends { a: number }>(record: R): R & { a
by mixedCase 5y ago
FWIW, you can achieve row polymorphism in TypeScript, although it's not super intuitive.
function rowPolymorphic<R extends { a: number }>(record: R): R & { a: string } {
return {
...record,
a: record.a.toString(),
}
}
const rec = rowPolymorphic({
a: 123,
b: "string",
})
console.log(rec.b)