Closed
Description
TypeScript Version: 2.4.2
Code
/*!
*
* Copyright 2017 - acrazing
*
* @author acrazing [email protected]
* @since 2017-08-16 15:56:19
* @version 1.0.0
* @desc index.ts
*/
export interface IOptions {
name: string;
}
export function config<T extends IOptions, K extends keyof T>(key: K, value: T[K]): void {
console.log(key, value)
}
export interface IClass {
config<T extends IOptions, K extends keyof T>(key: K, value: T[K]): void;
}
export class Class implements IClass {
config<T extends IOptions, K extends keyof T>(key: K, value: T[K]): void {
console.log(key, value)
}
}
Expected behavior:
No Error
Actual behavior:
index.ts(23,14): error TS2420: Class 'Class' incorrectly implements interface 'IClass'.
Types of property 'config' are incompatible.
Type '<T extends IOptions, K extends keyof T>(key: K, value: T[K]) => void' is not assignable to type '<T extends IOptions, K extends keyof T>(key: K, value: T[K]) => void'. Two different types with this name exist, but they are unrelated.
Types of parameters 'key' and 'key' are incompatible.
Type 'K' is not assignable to type '"name"'.
Type 'keyof T' is not assignable to type '"name"'.