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

Function parseImportCall

packages/babel-parser/src/parser/expression.ts:3074–3095  ·  view source on GitHub ↗
(
    this: Parser,
    node: Undone<N.ImportExpression>,
  )

Source from the content-addressed store, hash-verified

3072
3073 // https://tc39.es/ecma262/#prod-ImportCall
3074 parseImportCall(
3075 this: Parser,
3076 node: Undone<N.ImportExpression>,
3077 ): N.ImportExpression {
3078 this.expect(tt.parenL);
3079 const args = this.parseCallExpressionArguments();
3080 if (args.length === 0 || args.length > 2) {
3081 this.raise(Errors.ImportCallArity, node, node);
3082 } else {
3083 for (const arg of args) {
3084 if (arg.type === "SpreadElement") {
3085 this.raise(Errors.ImportCallSpreadArgument, arg, node);
3086 }
3087 }
3088 }
3089 // @ts-expect-error we allow SpreadElement for error recovery
3090 node.source = args[0];
3091 // @ts-expect-error we allow SpreadElement for error recovery
3092 node.options = args[1] ?? null;
3093
3094 return this.finishNode(node, "ImportExpression");
3095 }
3096
3097 // Enable topic references from outer contexts within Hack-style pipe bodies.
3098 // The function modifies the parser's hack pipeline flags to enable or disable

Callers

nothing calls this directly

Calls 1

finishNodeMethod · 0.80

Tested by

no test coverage detected