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

Function parseNamedImportSpecifiers

packages/babel-parser/src/parser/statement.ts:3321–3349  ·  view source on GitHub ↗
(node: Undone<N.ImportDeclaration>)

Source from the content-addressed store, hash-verified

3319 }
3320
3321 parseNamedImportSpecifiers(node: Undone<N.ImportDeclaration>) {
3322 let first = true;
3323 this.expect(tt.braceL);
3324 while (!this.eat(tt.braceR)) {
3325 if (first) {
3326 first = false;
3327 } else {
3328 // Detect an attempt to deep destructure
3329 if (this.eat(tt.colon)) {
3330 throw this.raise(Errors.DestructureNamedImport, this.state.startLoc);
3331 }
3332
3333 this.expect(tt.comma);
3334 if (this.eat(tt.braceR)) break;
3335 }
3336
3337 const specifier = this.startNode<N.ImportSpecifier>();
3338 const importedIsString = this.match(tt.string);
3339 const isMaybeTypeOnly = this.isContextual(tt._type);
3340 specifier.imported = this.parseModuleExportName();
3341 const importSpecifier = this.parseImportSpecifier(
3342 specifier,
3343 importedIsString,
3344 node.importKind === "type" || node.importKind === "typeof",
3345 isMaybeTypeOnly,
3346 );
3347 node.specifiers.push(importSpecifier);
3348 }
3349 }
3350
3351 // https://tc39.es/ecma262/#prod-ImportSpecifier
3352 // The specifier is validated later by checkImportSpecifier.

Callers

nothing calls this directly

Calls 3

matchMethod · 0.80
parseImportSpecifierMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected