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.

interface A { a: string; }<br />

interface B extends A { b: string; }<br />

interface C extends B { c: string; }<br />

interface G {<br />

x: T;<br />

y: U;<br />

}<br />

var v1: G;<br />

// Ok<br />

var v2: G; // Ok, equivalent to G<br />

var v3: G;<br />

// Error, A not valid argument for U<br />

var v4: G; // Ok<br />

var v5: G;<br />

// Ok<br />

var v6: G;<br />

// Error, wrong number of arguments<br />

var v7: G;<br />

// Error, no arguments<br />

A type argument is simply a Type and may itself be a type reference to a generic type, as demonstrated by<br />

'v4' in the example above.<br />

As described in section 3.6, a type reference to a generic type G designates a type wherein all occurrences<br />

of G's type parameters have been replaced with the actual type arguments supplied in the type reference.<br />

For example, the declaration of 'v1' above is equivalent to:<br />

var v1: {<br />

x: { a: string; }<br />

y: { a: string; b: string; c: string };<br />

};<br />

3.7.3 Object Type Literals<br />

An object type literal defines an object type by specifying the set of members that are statically<br />

considered to be present in instances of the type. Object type literals can be given names using interface<br />

declarations but are otherwise anonymous.<br />

ObjectType:<br />

{ TypeBody opt }<br />

TypeBody:<br />

TypeMemberList ; opt<br />

TypeMemberList:<br />

TypeMember<br />

TypeMemberList ; TypeMember<br />

37

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

Saved successfully!

Ooh no, something went wrong!