(node)
| 88942 | } |
| 88943 | } |
| 88944 | function checkGrammarProperty(node) { |
| 88945 | if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */) { |
| 88946 | return grammarErrorOnNode(node.parent.members[0], ts.Diagnostics.A_mapped_type_may_not_declare_properties_or_methods); |
| 88947 | } |
| 88948 | if (ts.isClassLike(node.parent)) { |
| 88949 | if (ts.isStringLiteral(node.name) && node.name.text === "constructor") { |
| 88950 | return grammarErrorOnNode(node.name, ts.Diagnostics.Classes_may_not_have_a_field_named_constructor); |
| 88951 | } |
| 88952 | if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type)) { |
| 88953 | return true; |
| 88954 | } |
| 88955 | if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { |
| 88956 | return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); |
| 88957 | } |
| 88958 | } |
| 88959 | else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { |
| 88960 | if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { |
| 88961 | return true; |
| 88962 | } |
| 88963 | if (node.initializer) { |
| 88964 | return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); |
| 88965 | } |
| 88966 | } |
| 88967 | else if (ts.isTypeLiteralNode(node.parent)) { |
| 88968 | if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { |
| 88969 | return true; |
| 88970 | } |
| 88971 | if (node.initializer) { |
| 88972 | return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); |
| 88973 | } |
| 88974 | } |
| 88975 | if (node.flags & 16777216 /* NodeFlags.Ambient */) { |
| 88976 | checkAmbientInitializer(node); |
| 88977 | } |
| 88978 | if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || |
| 88979 | node.flags & 16777216 /* NodeFlags.Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { |
| 88980 | var message = node.initializer |
| 88981 | ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions |
| 88982 | : !node.type |
| 88983 | ? ts.Diagnostics.Declarations_with_definite_assignment_assertions_must_also_have_type_annotations |
| 88984 | : ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context; |
| 88985 | return grammarErrorOnNode(node.exclamationToken, message); |
| 88986 | } |
| 88987 | } |
| 88988 | function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { |
| 88989 | // A declare modifier is required for any top level .d.ts declaration except export=, export default, export as namespace |
| 88990 | // interfaces and imports categories: |
no test coverage detected