I am currently developing an Object patching utility function with the following code snippet
class Test{
a:number;
b:number;
}
var c:Test={a:0,b:1}
function patchable<T>(obj:T){
return {
patch:function<K>(prop:K){
return patchable({...obj,...prop})},
value:function():T{return obj}
}
}
c=patchable(c).patch({notAllow:94}).value()
Is it feasible in typescript to restrict the patch
function to only accept objects containing properties that are present in the Test
interface, meaning K
can exclusively have keys available in T