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.

f < T1, T2, ... > ( p1, p2, ... ) : R ;<br />

f < U1, U2, ... > ( q1, q2, ... ) : S ;<br />

...<br />

is equivalent to<br />

f : {<br />

< T1, T2, ... > ( p1, p2, ... ) : R ;<br />

< U1, U2, ... > ( q1, q2, ... ) : S ;<br />

...<br />

} ;<br />

In the following example of an object type<br />

{<br />

}<br />

func1(x: number): number;<br />

func2: (x: number) => number;<br />

func3: { (x: number): number };<br />

// Method signature<br />

// Function type literal<br />

// Object type literal<br />

the properties 'func1', 'func2', and 'func3' are all of the same type, namely an object type with a single call<br />

signature taking a number and returning a number. Likewise, in the object type<br />

{<br />

}<br />

func4(x: number): number;<br />

func4(s: string): string;<br />

func5: {<br />

(x: number): number;<br />

(s: string): string;<br />

};<br />

the properties 'func4' and 'func5' are of the same type, namely an object type with two call signatures<br />

taking and returning number and string respectively.<br />

3.9 Type Aliases<br />

A type alias declaration introduces a type alias in the containing module.<br />

TypeAliasDeclaration:<br />

type Identifier = Type ;<br />

A type alias serves as an alias for the type specified in the type alias declaration. Unlike an interface<br />

declaration, which always introduces a named object type, a type alias declaration can introduce a name<br />

for any kind of type, including primitive types and union types.<br />

47

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

Saved successfully!

Ooh no, something went wrong!