Reputation: 5147
(function() : Contract {
…})
.
I was expecting IIFE but this colon? It’s not a label?
Upvotes: 0
Views: 232
Reputation: 370819
This is TypeScript syntax, not JavaScript. The colon indicates that the function will return something which is of type Contract.
For example, with
const foo = (function(): Foo {
// lots of code
return someExpression;
})();
this would indicate - and have TypeScript require - that the someExpression
is of type Foo.
In TypeScript, noting the return type of functions like this is usually optional. Most of the time, you can omit it entirely and let TS infer it automatically if you wish. (which is what I prefer to cut down on syntax noise)
Upvotes: 4