23.06.2015 Views

TypeScript Language Specification v1.5

TypeScript Language Specification v1.5

TypeScript Language Specification v1.5

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Tuple types assign numeric names to each of their elements and elements are therefore strongly typed<br />

when accessed using bracket notation with a numeric literal:<br />

var data: [string, number] = ["five", 5];<br />

var s = data[0]; // string<br />

var n = data[1]; // number<br />

4.11 The new Operator<br />

A new operation has one of the following forms:<br />

new C<br />

new C ( ... )<br />

new C < ... > ( ... )<br />

where C is an expression. The first form is equivalent to supplying an empty argument list. C must be of<br />

type Any or of an object type with one or more construct or call signatures. The operation is processed as<br />

follows at compile-time:<br />

<br />

<br />

<br />

If C is of type Any, any argument list is permitted and the result of the operation is of type Any.<br />

If C has one or more apparent construct signatures (section 3.10.1), the expression is processed in<br />

the same manner as a function call, but using the construct signatures as the initial set of<br />

candidate signatures for overload resolution. The result type of the function call becomes the<br />

result type of the operation.<br />

If C has no apparent construct signatures but one or more apparent call signatures, the<br />

expression is processed as a function call. A compile-time error occurs if the result of the function<br />

call is not Void. The type of the result of the operation is Any.<br />

4.12 Function Calls<br />

Function calls are extended from JavaScript to optionally include type arguments.<br />

Arguments: ( Modified )<br />

TypeArguments opt ( ArgumentList opt )<br />

A function call takes one of the forms<br />

func ( ... )<br />

func < ... > ( ... )<br />

where func is an expression of a function type or of type Any. The function expression is followed by an<br />

optional type argument list (section 3.5.2) and an argument list.<br />

67

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!