Reputation: 592
I saw in a javascript code written by a young guy this function
function foo(e:MouseEvent){
...
}
I want to know what does e:MouseEvent do?
Upvotes: 19
Views: 9711
Reputation: 2773
'e:MouseEvent' is a named parameter with a type declaration in typescript. A colon is used in typescript parameters to bind a parameter to a specific type which, in this case, is type 'MouseEvent'.
e is often used as the parameter name for a javascript event. Given the type it's likely a function that responds to a click event.
You can read more details about the syntax for it under the 'Function Types' heading of TypeScript's official documentation: https://www.typescriptlang.org/docs/handbook/functions.html.
Upvotes: 23