Here is a class:
const COMMANDS = [
"get-myanimelist-staff-urls",
"get-myanimelist-anime-explicit-genres",
"get-myanimelist-anime-genres",
"get-myanimelist-anime-themes"
...
];
class Shiinobi {
constructor() {
COMMANDS.forEach((command) => {
this[command.replaceAll("-", "_")] = async (...args: any[]) => {
const id = args[0];
return await this.#spawn({ command, id: id });
};
});
}
...
and I use this Shiinobi
class like:
const shiinobi = new Shiinobi();
const res = await shiinobi.get_myanimelist_staff_urls();
this is basically a valid code since constructor
creates such methods.
but there is no type for such methods:
shiinobi.get_myanimelist_staff_urls()
this code shows ts-error
I tried with typescript custom Utility
type, but no hope.
New contributor
moonlitgrace is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1