You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classGenericClass<T>{payload: T;}vargenericObject=newGenericClass<{greeting: string}>();functiongenericFunction<T>(object: GenericClass<T>,callback: (payload: T)=>void){callback(object.payload);}// WorksgenericFunction(genericObject,(payload)=>{// Here TS understands that payload have a property greeting// and that payload.greeting is a string.});// Fails to compile with "Type 'T' has no property 'greeting' and no index signature.".// Type of greeting is anygenericFunction(genericObject,({greeting})=>{});
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: