Function with Enum - TYPESCRIPT

Asked

Viewed 101 times

1

Good need to put a function in an Enum in typescript as in the example below:

export enum dataTableFunc{
    'edit'= teste()
}


function teste(event.button){
//
}

In this Function that I am trying to pass to Enum should still receive one or more parameters, this will be defined at the time of Function. And my question is this, is it possible? If yes, how can I do that? I did some research in the documentation but I was not very successful....

  • Have you ever just tried 'edit': teste, without the parentheses?

  • Already, typescript does not allow.

  • 1

    The enum is defined with = and not : still doesn’t seem like a case to use enum since this is dynamically constructed information. enum general rule is something static defined before the program launch.

  • @Isac thank you so much for the correction, I had not even noticed I did right in the editor here and I didn’t even touch. But in relation to typescript static I agree, but in doc it shows the possibility of working with class, but not the way I want. I thought of another approach without being with In a couple solve my problem. If it works I will close the question here.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.