PropertyDefinition: ( Modified )   IdentifierReference   CoverInitializedName   PropertyName  AssignmentExpression   PropertyNameCallSignature{FunctionBody}   GetAccessor   SetAccessor

      GetAccessor:   getPropertyName  )TypeAnnotationopt{FunctionBody}

      SetAccessor:    PropertyName(BindingIdentifierOrPatternTypeAnnotationopt){FunctionBody

    The type of an object literal is an object type with the set of properties specified by the property assignments in the object literal. A get and set accessor may specify the same property name, but otherwise it is an error to specify multiple property assignments for the same property.

    is equivalent to

    Likewise, a property assignment of the form

    is equivalent to

    Each property assignment in an object literal is processed as follows:

    • If the object literal is contextually typed and the contextual type contains a property with a matching name, the property assignment is contextually typed by the type of that property.
    • Otherwise, if the object literal is contextually typed, if the contextual type contains a numeric index signature, and if the property assignment specifies a numeric property name, the property assignment is contextually typed by the type of the numeric index signature.
    • Otherwise, the property assignment is processed without a contextual type.

    A get accessor declaration is processed in the same manner as an ordinary function declaration (section ) with no parameters. A set accessor declaration is processed in the same manner as an ordinary function declaration with a single parameter and a Void return type. When both a get and set accessor is declared for a property:

    • If both accessors include type annotations, the specified types must be identical.
    • If neither accessor includes a type annotation, the inferred return type of the get accessor becomes the parameter type of the set accessor.

    If a get accessor is declared for a property, the return type of the get accessor becomes the type of the property. If only a set accessor is declared for a property, the parameter type (which may be type Any if no type annotation is present) of the set accessor becomes the type of the property.

    When an object literal is contextually typed by a type that includes a string index signature, the resulting type of the object literal includes a string index signature with the union type of the types of the properties declared in the object literal, or the Undefined type if the object literal is empty. Likewise, when an object literal is contextually typed by a type that includes a numeric index signature, the resulting type of the object literal includes a numeric index signature with the union type of the types of the numerically named properties (section 3.9.4) declared in the object literal, or the Undefined type if the object literal declares no numerically named properties.

    If the PropertyName of a property assignment is a computed property name that doesn’t denote a well-known symbol (), the construct is considered a dynamic property assignment. The following rules apply to dynamic property assignments:

    • A dynamic property assignment does not introduce a property in the type of the object literal.
    • The name associated with a dynamic property assignment is considered to be a numeric property name if the property name expression is of type Any or the Number primitive type.