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

Function parseNamedImportSpecifiers

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

Source from the content-addressed store, hash-verified

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