TypeHint[Yield] :
[~Yield] IdentifierReference[~Yield]
number
string
boolean
void
PropertyDefinition[Yield] :
IdentifierReference[?Yield] TypeHint[?Yield]opt
CoverInitializedName[?Yield]
PropertyName[?Yield] : AssignmentExpression[In, ?Yield]
MethodDefinition[?Yield]
PropertyName[Yield,GeneratorParameter] :
LiteralPropertyName
[+GeneratorParameter] ComputedPropertyName TypeHint[?Yield]opt
[~GeneratorParameter] ComputedPropertyName[?Yield] TypeHint[?Yield]opt
LiteralPropertyName :
IdentifierName TypeHintopt
StringLiteral
NumericLiteral
CoverInitializedName[Yield] :
IdentifierReference[?Yield] TypeHint[?Yield]opt Initializer[In, ?Yield]
12.14.5 Destructuring Assignment
AssignmentProperty[Yield] :
IdentifierReference[?Yield] TypeHint[?Yield]opt Initializer[In,?Yield]opt
PropertyName TypeHint[?Yield] : AssignmentElement[?Yield]
13.3.1 Let and Const Declarations
LexicalBinding[In, Yield] :
BindingIdentifier[?Yield] TypeHint[?Yield]opt Initializer[?In, ?Yield]opt
BindingPattern[?Yield] Initializer[?In, ?Yield]
VariableDeclaration[In, Yield] :
BindingIdentifier[?Yield] TypeHint[?Yield]opt Initializer[?In, ?Yield]opt
BindingPattern[?Yield] Initializer[?In, ?Yield]
13.3.3 Destructuring Binding Patterns
SingleNameBinding [Yield, GeneratorParameter] :
[+GeneratorParameter] BindingIdentifier[Yield] TypeHint[?Yield]opt Initializer[In]opt
[~GeneratorParameter] BindingIdentifier[?Yield] TypeHint[?Yield]opt Initializer[In, ?Yield]opt
ForBinding[Yield] :
BindingIdentifier[?Yield] TypeHint[?Yield]opt
BindingPattern[?Yield]
FunctionDeclaration[Yield, Default] :
function BindingIdentifier[?Yield] ( FormalParameters ) TypeHint[?Yield]opt { FunctionBody }
[+Default] function ( FormalParameters ) TypeHint[?Yield]opt { FunctionBody }
FunctionExpression :
function BindingIdentifieropt ( FormalParameters ) TypeHint[?Yield]opt { FunctionBody }
FormalParameter[Yield,GeneratorParameter] :
BindingElement[?Yield, ?GeneratorParameter] TypeHint[?Yield]opt
14.2 Arrow Function Definitions
ArrowParameters[Yield] :
BindingIdentifier[?Yield] TypeHint[?Yield]opt
CoverParenthesizedExpressionAndArrowParameterList[?Yield] TypeHint[?Yield]opt
TODO: semantics of what TypeHint
is attached to.
MethodDefinition[Yield] :
PropertyName[?Yield] ( StrictFormalParameters ) TypeHint[?Yield]opt { FunctionBody }
GeneratorMethod[?Yield]
get PropertyName[?Yield] ( ) TypeHint[?Yield]opt { FunctionBody }
set PropertyName[?Yield] ( PropertySetParameterList ) TypeHint[?Yield]opt { FunctionBody }
TODO: static semantics of set's typehint, it should be a syntax error if it's not empty, or "void"
14.4 Generator Function Definitions
GeneratorMethod[Yield] :
* PropertyName[?Yield] ( StrictFormalParameters[Yield,GeneratorParameter] ) TypeHint[?Yield]opt { GeneratorBody }
GeneratorDeclaration[Yield, Default] :
function * BindingIdentifier[?Yield] ( FormalParameters[Yield,GeneratorParameter] ) TypeHint[?Yield]opt { GeneratorBody }
[+Default] function * ( FormalParameters[Yield,GeneratorParameter] ) TypeHint[?Yield]opt { GeneratorBody }
GeneratorExpression :
function * BindingIdentifier[Yield]opt ( FormalParameters[Yield,GeneratorParameter] ) TypeHint[?Yield]opt { GeneratorBody }
Type Hinting:
Type Checking/Annotations: