(
this: Parser,
refExpressionErrors?: ExpressionErrors | null,
)
| 2149 | |
| 2150 | // https://tc39.es/ecma262/#prod-PropertyDefinition |
| 2151 | parsePropertyDefinition( |
| 2152 | this: Parser, |
| 2153 | refExpressionErrors?: ExpressionErrors | null, |
| 2154 | ): N.ObjectMember | N.SpreadElement { |
| 2155 | const decorators = []; |
| 2156 | const decoratorsStartLoc = this.state.startLoc; |
| 2157 | if (this.match(tt.at)) { |
| 2158 | if (this.hasPlugin("decorators")) { |
| 2159 | this.raise(Errors.UnsupportedPropertyDecorator, decoratorsStartLoc); |
| 2160 | } |
| 2161 | |
| 2162 | // we needn't check if decorators (stage 0) plugin is enabled since it's checked by |
| 2163 | // the call to this.parseDecorator |
| 2164 | while (this.match(tt.at)) { |
| 2165 | decorators.push(this.parseDecorator()); |
| 2166 | } |
| 2167 | } |
| 2168 | |
| 2169 | if (this.match(tt.ellipsis)) { |
| 2170 | if (decorators.length) this.unexpected(); |
| 2171 | return this.parseSpread(); |
| 2172 | } |
| 2173 | |
| 2174 | const prop = this.startNodeAt<N.ObjectProperty | N.ObjectMethod>( |
| 2175 | decoratorsStartLoc, |
| 2176 | ); |
| 2177 | let isAsync = false; |
| 2178 | let isAccessor = false; |
| 2179 | let startLoc; |
| 2180 | |
| 2181 | if (decorators.length) { |
| 2182 | prop.decorators = decorators; |
| 2183 | } |
| 2184 | |
| 2185 | // @ts-expect-error todo: Undocumented property for ESTree compatibility. |
| 2186 | // Consider move to the ESTree plugin |
| 2187 | prop.method = false; |
| 2188 | |
| 2189 | if (refExpressionErrors) { |
| 2190 | startLoc = this.state.startLoc; |
| 2191 | } |
| 2192 | |
| 2193 | let isGenerator = this.eat(tt.star); |
| 2194 | this.parsePropertyNamePrefixOperator(prop); |
| 2195 | const containsEsc = this.state.containsEsc; |
| 2196 | this.parsePropertyName(prop, refExpressionErrors); |
| 2197 | |
| 2198 | if (!isGenerator && !containsEsc && this.maybeAsyncOrAccessorProp(prop)) { |
| 2199 | const { key } = prop; |
| 2200 | const keyName = key.name; |
| 2201 | // https://tc39.es/ecma262/#prod-AsyncMethod |
| 2202 | // https://tc39.es/ecma262/#prod-AsyncGeneratorMethod |
| 2203 | if (keyName === "async" && !this.hasPrecedingLineBreak()) { |
| 2204 | isAsync = true; |
| 2205 | this.resetPreviousNodeTrailingComments(key); |
| 2206 | isGenerator = this.eat(tt.star); |
| 2207 | this.parsePropertyName(prop); |
| 2208 | } |
nothing calls this directly
no test coverage detected