Resolving the Issue
Upon examining the error message, it appears that:
The object literal can only define known properties, and 'a' is not present in the type '{ key: number; }'
This discrepancy arises between an object literal and a specifically named object.
Nevertheless, you have the option to modify your function to accommodate this change for successful compilation.
const func1 = <T extends {key: number}>(input: T)=>{
console.log(input)
}
Revision
You may be wondering why this alteration is necessary, rather than how to implement it. This adjustment was actually introduced as a feature in TypeScript 1.6 to detect typographical errors made by developers in property names.
If preferred, you can enable the suppressImplicitAnyIndexErrors
setting in your tsconfig file to ignore this issue. However, it is generally discouraged by TypeScript.