Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions crates/oxc_ast/src/ast/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2466,26 +2466,32 @@ pub enum ImportDeclarationSpecifier<'a> {
ImportNamespaceSpecifier(Box<'a, ImportNamespaceSpecifier<'a>>) = 2,
}

// import {imported} from "source"
// import {imported as local} from "source"
/// Import specifier.
///
/// ```ts
/// import { imported, imported2 } from "source";
/// // ^^^^^^^^ ^^^^^^^^^
/// import { imported as local } from "source";
/// // ^^^^^^^^^^^^^^^^^
/// import { type Foo } from "source";
/// // ^^^^^^^^
/// ```
///
/// In the case of `import { foo }`, `imported` and `local` both are the same name,
/// and have the same `Span`.
#[ast(visit)]
#[derive(Debug)]
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
pub struct ImportSpecifier<'a> {
pub span: Span,
/// Imported symbol.
/// Can only be `IdentifierName` or `StringLiteral`.
pub imported: ModuleExportName<'a>,
/// The name of the imported symbol.
///
/// ## Example
/// ```ts
/// // local and imported name are the same
/// import { Foo } from 'foo';
/// // ^^^
/// // imports can be renamed, changing the local name
/// import { Foo as Bar } from 'foo';
/// // ^^^
/// ```
/// Binding for local symbol.
pub local: BindingIdentifier<'a>,
/// Value or type.
/// `import { foo }` -> `ImportOrExportKind::Value`
/// `import { type Bar }` -> `ImportOrExportKind::Type`
#[ts]
pub import_kind: ImportOrExportKind,
}
Expand Down
18 changes: 9 additions & 9 deletions crates/oxc_ast/src/generated/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7482,9 +7482,9 @@ impl<'a> AstBuilder<'a> {
///
/// ## Parameters
/// * `span`: The [`Span`] covering this node
/// * `imported`
/// * `local`: The name of the imported symbol.
/// * `import_kind`
/// * `imported`: Imported symbol.
/// * `local`: Binding for local symbol.
/// * `import_kind`: Value or type.
#[inline]
pub fn import_declaration_specifier_import_specifier(
self,
Expand Down Expand Up @@ -7544,9 +7544,9 @@ impl<'a> AstBuilder<'a> {
///
/// ## Parameters
/// * `span`: The [`Span`] covering this node
/// * `imported`
/// * `local`: The name of the imported symbol.
/// * `import_kind`
/// * `imported`: Imported symbol.
/// * `local`: Binding for local symbol.
/// * `import_kind`: Value or type.
#[inline]
pub fn import_specifier(
self,
Expand All @@ -7565,9 +7565,9 @@ impl<'a> AstBuilder<'a> {
///
/// ## Parameters
/// * `span`: The [`Span`] covering this node
/// * `imported`
/// * `local`: The name of the imported symbol.
/// * `import_kind`
/// * `imported`: Imported symbol.
/// * `local`: Binding for local symbol.
/// * `import_kind`: Value or type.
#[inline]
pub fn alloc_import_specifier(
self,
Expand Down
Loading