This is a code snippet from a class method:
class BinderScoreService<T> extends Binder {
public bindTeacher<K extends keyof T>(key: K) {
}
}
When using this method and passing a string value as a parameter, TypeScript verifies if it matches a key of type T
:
bindTeacher('id');
How can I pass another parameter and perform the same check?
For example:
bindTeacher<ISecond>('id', 'second');
I attempted the following:
public bindTeacher<K extends keyof T, KB extends keyof B>(key: K, key2: B) {
}
And then calling it like this:
bindTeacher<ISecond>('id', 'second');