(node, inDestructuring)
| 88279 | return !!exclamationToken && grammarErrorOnNode(exclamationToken, message); |
| 88280 | } |
| 88281 | function checkGrammarObjectLiteralExpression(node, inDestructuring) { |
| 88282 | var seen = new ts.Map(); |
| 88283 | for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { |
| 88284 | var prop = _a[_i]; |
| 88285 | if (prop.kind === 298 /* SyntaxKind.SpreadAssignment */) { |
| 88286 | if (inDestructuring) { |
| 88287 | // a rest property cannot be destructured any further |
| 88288 | var expression = ts.skipParentheses(prop.expression); |
| 88289 | if (ts.isArrayLiteralExpression(expression) || ts.isObjectLiteralExpression(expression)) { |
| 88290 | return grammarErrorOnNode(prop.expression, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); |
| 88291 | } |
| 88292 | } |
| 88293 | continue; |
| 88294 | } |
| 88295 | var name = prop.name; |
| 88296 | if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { |
| 88297 | // If the name is not a ComputedPropertyName, the grammar checking will skip it |
| 88298 | checkGrammarComputedPropertyName(name); |
| 88299 | } |
| 88300 | if (prop.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { |
| 88301 | // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern |
| 88302 | // outside of destructuring it is a syntax error |
| 88303 | grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern); |
| 88304 | } |
| 88305 | if (name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { |
| 88306 | grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); |
| 88307 | } |
| 88308 | // Modifiers are never allowed on properties except for 'async' on a method declaration |
| 88309 | if (prop.modifiers) { |
| 88310 | for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { |
| 88311 | var mod = _c[_b]; |
| 88312 | if (mod.kind !== 131 /* SyntaxKind.AsyncKeyword */ || prop.kind !== 169 /* SyntaxKind.MethodDeclaration */) { |
| 88313 | grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); |
| 88314 | } |
| 88315 | } |
| 88316 | } |
| 88317 | // ECMA-262 11.1.5 Object Initializer |
| 88318 | // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true |
| 88319 | // a.This production is contained in strict code and IsDataDescriptor(previous) is true and |
| 88320 | // IsDataDescriptor(propId.descriptor) is true. |
| 88321 | // b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true. |
| 88322 | // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. |
| 88323 | // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true |
| 88324 | // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields |
| 88325 | var currentKind = void 0; |
| 88326 | switch (prop.kind) { |
| 88327 | case 297 /* SyntaxKind.ShorthandPropertyAssignment */: |
| 88328 | checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); |
| 88329 | // falls through |
| 88330 | case 296 /* SyntaxKind.PropertyAssignment */: |
| 88331 | // Grammar checking for computedPropertyName and shorthandPropertyAssignment |
| 88332 | checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); |
| 88333 | if (name.kind === 8 /* SyntaxKind.NumericLiteral */) { |
| 88334 | checkGrammarNumericLiteral(name); |
| 88335 | } |
| 88336 | currentKind = 4 /* DeclarationMeaning.PropertyAssignment */; |
| 88337 | break; |
| 88338 | case 169 /* SyntaxKind.MethodDeclaration */: |
no test coverage detected