Minor note: Is it possible to include method in TypeScript interface? may seem similar but it's asking the reverse of what this question is.
I have a typescript method that uses an options parameter that works and compiles fine:
async addKickingRule(options: KickingRuleOptions = {
time: 60 * MINUTES,
privileges: ALL_PRIVILEGES
}) {
...
}
It uses an interface defined elsewhere:
interface KickingRuleOptions {
time: number,
privileges: Privileges[],
channel?: string,
userID?: string,
ipAddress?: string
}
Again, this works fine. However I feel it would be easier for my colleagues if the interface was defined in-the body of the method.
Can I use an options object in a typescript method and define the options interface in the body of the method?