23.06.2015 Views

TypeScript Language Specification v1.5

TypeScript Language Specification v1.5

TypeScript Language Specification v1.5

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

A spread element must specify an expression of an array-like type (section 3.3.2), or otherwise an error<br />

occurs.<br />

The rules above mean that an array literal is always of an array type, unless it is contextually typed by a<br />

tuple-like type. For example<br />

var a = [1, 2];<br />

// number[]<br />

var b = ["hello", true];<br />

// (string | boolean)[]<br />

var c: [number, string] = [3, "three"]; // [number, string]<br />

When the output target is ECMAScript 3 or 5, array literals containing spread elements are rewritten to<br />

invocations of the concat method. For example, the assignments<br />

var a = [2, 3, 4];<br />

var b = [0, 1, ...a, 5, 6];<br />

are rewritten to<br />

var a = [2, 3, 4];<br />

var b = [0, 1].concat(a, [5, 6]);<br />

4.7 Parentheses<br />

A parenthesized expression<br />

( expr )<br />

has the same type and classification as the contained expression itself. Specifically, if the contained<br />

expression is classified as a reference, so is the parenthesized expression.<br />

4.8 The super Keyword<br />

The super keyword can be used in expressions to reference base class properties and the base class<br />

constructor.<br />

CallExpression: ( Modified )<br />

…<br />

super ( ArgumentList opt )<br />

super . IdentifierName<br />

4.8.1 Super Calls<br />

Super calls consist of the keyword super followed by an argument list enclosed in parentheses. Super calls<br />

are only permitted in constructors of derived classes, as described in section 8.3.2.<br />

61

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

Saved successfully!

Ooh no, something went wrong!