I'm currently working on developing a function that can return a Set containing the keys of a class. However, I am struggling to determine the correct definition for this function.
class Bot {
public no01: number;
public no02: number;
constructor(no01: number, no02: number) {
this.no01 = no01;
this.no02 = no02;
}
}
function getKeySet(): Set<keyof Bot> {
return new Set(["no01"]);
}
Unfortunately, when testing it out, I consistently encounter the following error message:
"Type 'Set<string>' is not assignable to type 'Set<keyof Bot>'.
Type 'string' is not assignable to type 'keyof Bot'."