MCPcopy Create free account
hub / github.com/babel/babel / parseNewOrNewTarget

Function parseNewOrNewTarget

packages/babel-parser/src/parser/expression.ts:1952–1976  ·  view source on GitHub ↗
(this: Parser)

Source from the content-addressed store, hash-verified

1950 }
1951
1952 parseNewOrNewTarget(this: Parser): N.NewExpression | N.MetaProperty {
1953 const node = this.startNode<N.NewExpression | N.MetaProperty>();
1954 this.next();
1955 if (this.match(tt.dot)) {
1956 // https://tc39.es/ecma262/#prod-NewTarget
1957 const meta = this.createIdentifier(
1958 this.startNodeAtNode<N.Identifier>(node),
1959 "new",
1960 );
1961 this.next();
1962 const metaProp = this.parseMetaProperty(
1963 node as Undone<N.MetaProperty>,
1964 meta,
1965 "target",
1966 );
1967
1968 if (!this.scope.allowNewTarget) {
1969 this.raise(Errors.UnexpectedNewTarget, metaProp);
1970 }
1971
1972 return metaProp;
1973 }
1974
1975 return this.parseNew(node as Undone<N.NewExpression>);
1976 }
1977
1978 // New's precedence is slightly tricky. It must allow its argument to
1979 // be a `[]` or dot subscript expression, but not a call — at least,

Callers

nothing calls this directly

Calls 2

nextMethod · 0.80
matchMethod · 0.80

Tested by

no test coverage detected