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

Function parseImportCall

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

Source from the content-addressed store, hash-verified

3080
3081 // https://tc39.es/ecma262/#prod-ImportCall
3082 parseImportCall(
3083 this: Parser,
3084 node: Undone<N.ImportExpression>,
3085 ): N.ImportExpression {
3086 this.expect(tt.parenL);
3087 const args = this.parseCallExpressionArguments();
3088 if (args.length === 0 || args.length > 2) {
3089 this.raise(Errors.ImportCallArity, node, node);
3090 } else {
3091 for (const arg of args) {
3092 if (arg.type === "SpreadElement") {
3093 this.raise(Errors.ImportCallSpreadArgument, arg, node);
3094 }
3095 }
3096 }
3097 // @ts-expect-error we allow SpreadElement for error recovery
3098 node.source = args[0];
3099 // @ts-expect-error we allow SpreadElement for error recovery
3100 node.options = args[1] ?? null;
3101
3102 return this.finishNode(node, "ImportExpression");
3103 }
3104
3105 // Enable topic references from outer contexts within Hack-style pipe bodies.
3106 // 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