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.

However, doing so means the following capabilities are lost:<br />

<br />

<br />

<br />

An interface can be named in an extends or implements clause, but a type alias for an object type<br />

literal cannot.<br />

An interface can have multiple merged declarations, but a type alias for an object type literal<br />

cannot.<br />

An interface can have type parameters, but a type alias for an object type literal cannot.<br />

3.10 Type Relationships<br />

Types in <strong>TypeScript</strong> have identity, subtype, supertype, and assignment compatibility relationships as<br />

defined in the following sections.<br />

3.10.1 Apparent Members<br />

The apparent members of a type are the members observed in subtype, supertype, and assignment<br />

compatibility relationships, as well as in the type checking of property accesses (section 4.10), new<br />

operations (section 4.11), and function calls (section 4.12). The apparent members of a type are<br />

determined as follows:<br />

<br />

<br />

<br />

<br />

<br />

The apparent members of the primitive types Number, Boolean, and String are the apparent<br />

members of the global interface types 'Number', 'Boolean', and 'String' respectively.<br />

The apparent members of an enum type are the apparent members of the global interface type<br />

'Number'.<br />

The apparent members of a type parameter are the apparent members of the base constraint<br />

(section 3.5.1) of that type parameter.<br />

The apparent members of an object type T are the combination of the following:<br />

o The declared and/or inherited members of T.<br />

o The properties of the global interface type 'Object' that aren't hidden by properties with<br />

the same name in T.<br />

o If T has one or more call or construct signatures, the properties of the global interface<br />

type 'Function' that aren't hidden by properties with the same name in T.<br />

The apparent members of a union type U are determined as follows:<br />

o If each type in U has an apparent property P, U has an apparent property P of a union<br />

type of the types of P from each type in U.<br />

o If each type in U has apparent call signatures and the sets of apparent call signatures are<br />

identical ignoring return types, U has the same set of call signatures, but with return types<br />

that are unions of the return types of the respective apparent call signatures from each<br />

type in U.<br />

o If each type in U has apparent construct signatures and the sets of apparent construct<br />

signatures are identical ignoring return types, U has the same set of construct signatures,<br />

but with return types that are unions of the return types of the respective apparent<br />

construct signatures from each type in U.<br />

49

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

Saved successfully!

Ooh no, something went wrong!