Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Type definition

A type definition is either used to define an alias to an existing type or used to define a variant inside an algebraic enum.

Syntax

type M = Map.<double, double>


// inside algebraic enums

type X(n : decimal)

Alias type definitions are allowed anywhere. When inside a class block, contributes a static property.

Variant type definitions are only allowed directly in the block of an algebraic enum.

    TypeDefinitionω :
      type IdentifierName TypeParametersopt = TypeExpression Semicolonω
      type AlgebraicVariantName ( Parameters ) Semicolonω
      type AlgebraicVariantName ( Parameters ) Blockopt
    AlgebraicVariantName :
      IdentifierName
      AlgebraicVariantName . IdentifierName