I want to be able to use a static method like this:
UpdateUrlAction.send('https://google.com')
UpdateCountAction.send(3)
I want to define that UpdateUrlAction.send only takes a string as the parameter, but UpdateCountAction accepts a number. The solution should be based on this general structure:
export default abstract class ChromeMessageAction {
static action: string
public static send(payload: Object|string|number) {
ChromeMessageService.send(this.action, payload)
}
}
export default class UpdateUrlAction extends ChromeMessageAction {
action = 'updateUrl'
payload: string
}
export default class UpdateUrlAction extends ChromeMessageAction {
action = 'updateCount'
payload: number
}
Is there some way to define the payload type without overriding the send method?