swc_estree_compat/swcify/
stmt.rs

1use swc_common::DUMMY_SP;
2use swc_ecma_ast::{
3    BlockStmt, BreakStmt, ClassDecl, ClassExpr, ContinueStmt, DebuggerStmt, DefaultDecl,
4    DoWhileStmt, EmptyStmt, ExportAll, ExportDecl, ExportDefaultDecl, ExportDefaultExpr,
5    ExportNamedSpecifier, ExprStmt, FnDecl, FnExpr, ForHead, ForInStmt, ForOfStmt, ForStmt, IfStmt,
6    ImportDecl, ImportNamedSpecifier, ImportSpecifier, ImportStarAsSpecifier, KeyValueProp,
7    LabeledStmt, Lit, ModuleDecl, ModuleItem, NamedExport, ObjectLit, Pat, Prop, PropName,
8    PropOrSpread, ReturnStmt, SwitchStmt, ThrowStmt, TryStmt, TsExportAssignment, TsInterfaceDecl,
9    TsModuleDecl, TsTypeAliasDecl, VarDecl, VarDeclKind, VarDeclOrExpr, VarDeclarator, WhileStmt,
10    WithStmt,
11};
12use swc_estree_ast::{
13    BlockStatement, BreakStatement, ClassDeclaration, ContinueStatement, DebuggerStatement,
14    DeclareClass, DeclareExportAllDeclaration, DeclareExportDeclaration, DeclareFunction,
15    DeclareInterface, DeclareModule, DeclareModuleExports, DeclareTypeAlias, DeclareVariable,
16    DoWhileStatement, EmptyStatement, ExportAllDeclaration, ExportDefaultDeclType,
17    ExportDefaultDeclaration, ExportKind, ExportNamedDeclaration, ExpressionStatement,
18    ForInStatement, ForOfStatement, ForStatement, ForStmtInit, ForStmtLeft, FunctionDeclaration,
19    IdOrString, IfStatement, ImportAttribute, ImportDeclaration, ImportKind,
20    ImportNamespaceSpecifier, ImportSpecifierType, LabeledStatement, ReturnStatement, Statement,
21    SwitchStatement, ThrowStatement, TryStatement, VariableDeclaration, VariableDeclarationKind,
22    VariableDeclarator, WhileStatement, WithStatement,
23};
24
25use super::Context;
26use crate::swcify::Swcify;
27
28impl Swcify for BlockStatement {
29    type Output = BlockStmt;
30
31    fn swcify(self, ctx: &Context) -> Self::Output {
32        BlockStmt {
33            span: ctx.span(&self.base),
34            stmts: self
35                .body
36                .swcify(ctx)
37                .into_iter()
38                .map(|v| v.expect_stmt())
39                .collect(),
40            ..Default::default()
41        }
42    }
43}
44
45impl Swcify for Statement {
46    type Output = ModuleItem;
47
48    fn swcify(self, ctx: &Context) -> Self::Output {
49        match self {
50            Statement::Block(v) => v.swcify(ctx).into(),
51            Statement::Break(v) => v.swcify(ctx).into(),
52            Statement::Continue(v) => v.swcify(ctx).into(),
53            Statement::Debugger(v) => v.swcify(ctx).into(),
54            Statement::DoWhile(v) => v.swcify(ctx).into(),
55            Statement::Empty(v) => v.swcify(ctx).into(),
56            Statement::Expr(v) => v.swcify(ctx).into(),
57            Statement::ForIn(v) => v.swcify(ctx).into(),
58            Statement::For(v) => v.swcify(ctx).into(),
59            Statement::FuncDecl(v) => v.swcify(ctx).into(),
60            Statement::If(v) => v.swcify(ctx).into(),
61            Statement::Labeled(v) => v.swcify(ctx).into(),
62            Statement::Return(v) => v.swcify(ctx).into(),
63            Statement::Switch(v) => v.swcify(ctx).into(),
64            Statement::Throw(v) => v.swcify(ctx).into(),
65            Statement::Try(v) => v.swcify(ctx).into(),
66            Statement::VarDecl(v) => v.swcify(ctx).into(),
67            Statement::While(v) => v.swcify(ctx).into(),
68            Statement::With(v) => v.swcify(ctx).into(),
69            Statement::ClassDecl(v) => v.swcify(ctx).into(),
70            Statement::ExportAllDecl(v) => ModuleItem::ModuleDecl(v.swcify(ctx).into()),
71            Statement::ExportDefaultDecl(v) => ModuleItem::ModuleDecl(v.swcify(ctx)),
72            Statement::ExportNamedDecl(v) => ModuleItem::ModuleDecl(v.swcify(ctx).into()),
73            Statement::ForOf(v) => v.swcify(ctx).into(),
74            Statement::ImportDecl(v) => ModuleItem::ModuleDecl(v.swcify(ctx).into()),
75            Statement::DeclClass(v) => v.swcify(ctx).into(),
76            Statement::DeclFunc(v) => v.swcify(ctx).into(),
77            Statement::DeclInterface(v) => v.swcify(ctx).into(),
78            Statement::DeclModule(v) => v.swcify(ctx).into(),
79            Statement::DeclareModuleExports(v) => ModuleItem::ModuleDecl(v.swcify(ctx).into()),
80            Statement::DeclTypeAlias(v) => v.swcify(ctx).into(),
81            Statement::DeclVar(v) => v.swcify(ctx).into(),
82            Statement::DeclExportDeclaration(v) => ModuleItem::ModuleDecl(v.swcify(ctx).into()),
83            Statement::DeclExportAllDeclaration(v) => ModuleItem::ModuleDecl(v.swcify(ctx).into()),
84            _ => {
85                todo!("swcify: {:?}", self)
86            }
87        }
88    }
89}
90
91impl Swcify for BreakStatement {
92    type Output = BreakStmt;
93
94    fn swcify(self, ctx: &Context) -> Self::Output {
95        BreakStmt {
96            span: ctx.span(&self.base),
97            label: self.label.swcify(ctx).map(|v| v.into()),
98        }
99    }
100}
101
102impl Swcify for ContinueStatement {
103    type Output = ContinueStmt;
104
105    fn swcify(self, ctx: &Context) -> Self::Output {
106        ContinueStmt {
107            span: ctx.span(&self.base),
108            label: self.label.swcify(ctx).map(|v| v.into()),
109        }
110    }
111}
112
113impl Swcify for DebuggerStatement {
114    type Output = DebuggerStmt;
115
116    fn swcify(self, ctx: &Context) -> Self::Output {
117        DebuggerStmt {
118            span: ctx.span(&self.base),
119        }
120    }
121}
122
123impl Swcify for DoWhileStatement {
124    type Output = DoWhileStmt;
125
126    fn swcify(self, ctx: &Context) -> Self::Output {
127        DoWhileStmt {
128            span: ctx.span(&self.base),
129            test: self.test.swcify(ctx),
130            body: Box::new(self.body.swcify(ctx).expect_stmt()),
131        }
132    }
133}
134
135impl Swcify for EmptyStatement {
136    type Output = EmptyStmt;
137
138    fn swcify(self, ctx: &Context) -> Self::Output {
139        EmptyStmt {
140            span: ctx.span(&self.base),
141        }
142    }
143}
144
145impl Swcify for ExpressionStatement {
146    type Output = ExprStmt;
147
148    fn swcify(self, ctx: &Context) -> Self::Output {
149        ExprStmt {
150            span: ctx.span(&self.base),
151            expr: self.expression.swcify(ctx),
152        }
153    }
154}
155
156impl Swcify for ForInStatement {
157    type Output = ForInStmt;
158
159    fn swcify(self, ctx: &Context) -> Self::Output {
160        ForInStmt {
161            span: ctx.span(&self.base),
162            left: self.left.swcify(ctx),
163            right: self.right.swcify(ctx),
164            body: Box::new(self.body.swcify(ctx).expect_stmt()),
165        }
166    }
167}
168
169impl Swcify for ForStmtLeft {
170    type Output = ForHead;
171
172    fn swcify(self, ctx: &Context) -> Self::Output {
173        match self {
174            ForStmtLeft::VarDecl(v) => ForHead::VarDecl(v.swcify(ctx).into()),
175            ForStmtLeft::LVal(v) => ForHead::Pat(v.swcify(ctx).into()),
176        }
177    }
178}
179
180impl Swcify for ForStatement {
181    type Output = ForStmt;
182
183    fn swcify(self, ctx: &Context) -> Self::Output {
184        ForStmt {
185            span: ctx.span(&self.base),
186            init: self.init.swcify(ctx),
187            test: self.test.swcify(ctx),
188            update: self.update.swcify(ctx),
189            body: Box::new(self.body.swcify(ctx).expect_stmt()),
190        }
191    }
192}
193
194impl Swcify for ForStmtInit {
195    type Output = VarDeclOrExpr;
196
197    fn swcify(self, ctx: &Context) -> Self::Output {
198        match self {
199            ForStmtInit::VarDecl(v) => VarDeclOrExpr::VarDecl(v.swcify(ctx).into()),
200            ForStmtInit::Expr(v) => VarDeclOrExpr::Expr(v.swcify(ctx)),
201        }
202    }
203}
204
205impl Swcify for FunctionDeclaration {
206    type Output = FnDecl;
207
208    fn swcify(self, ctx: &Context) -> Self::Output {
209        FnDecl {
210            ident: self.id.swcify(ctx).map(|v| v.into()).unwrap(),
211            declare: false,
212            function: swc_ecma_ast::Function {
213                params: self.params.swcify(ctx),
214                decorators: Default::default(),
215                span: ctx.span(&self.base),
216                body: Some(self.body.swcify(ctx)),
217                is_generator: false,
218                is_async: self.is_async.unwrap_or_default(),
219                ..Default::default()
220            }
221            .into(),
222        }
223    }
224}
225
226impl Swcify for IfStatement {
227    type Output = IfStmt;
228
229    fn swcify(self, ctx: &Context) -> Self::Output {
230        IfStmt {
231            span: ctx.span(&self.base),
232            test: self.test.swcify(ctx),
233            cons: Box::new(self.consequent.swcify(ctx).expect_stmt()),
234            alt: self
235                .alternate
236                .swcify(ctx)
237                .map(|v| v.expect_stmt())
238                .map(Box::new),
239        }
240    }
241}
242
243impl Swcify for LabeledStatement {
244    type Output = LabeledStmt;
245
246    fn swcify(self, ctx: &Context) -> Self::Output {
247        LabeledStmt {
248            span: ctx.span(&self.base),
249            label: self.label.swcify(ctx).into(),
250            body: Box::new(self.body.swcify(ctx).expect_stmt()),
251        }
252    }
253}
254
255impl Swcify for ReturnStatement {
256    type Output = ReturnStmt;
257
258    fn swcify(self, ctx: &Context) -> Self::Output {
259        ReturnStmt {
260            span: ctx.span(&self.base),
261            arg: self.argument.swcify(ctx),
262        }
263    }
264}
265
266impl Swcify for SwitchStatement {
267    type Output = SwitchStmt;
268
269    fn swcify(self, ctx: &Context) -> Self::Output {
270        SwitchStmt {
271            span: ctx.span(&self.base),
272            discriminant: self.discriminant.swcify(ctx),
273            cases: self.cases.swcify(ctx),
274        }
275    }
276}
277
278impl Swcify for swc_estree_ast::SwitchCase {
279    type Output = swc_ecma_ast::SwitchCase;
280
281    fn swcify(self, ctx: &Context) -> Self::Output {
282        swc_ecma_ast::SwitchCase {
283            span: ctx.span(&self.base),
284            test: self.test.swcify(ctx),
285            cons: self
286                .consequent
287                .swcify(ctx)
288                .into_iter()
289                .map(|v| v.expect_stmt())
290                .collect(),
291        }
292    }
293}
294
295impl Swcify for ThrowStatement {
296    type Output = ThrowStmt;
297
298    fn swcify(self, ctx: &Context) -> Self::Output {
299        ThrowStmt {
300            span: ctx.span(&self.base),
301            arg: self.argument.swcify(ctx),
302        }
303    }
304}
305
306impl Swcify for TryStatement {
307    type Output = TryStmt;
308
309    fn swcify(self, ctx: &Context) -> Self::Output {
310        TryStmt {
311            span: ctx.span(&self.base),
312            block: self.block.swcify(ctx),
313            handler: self.handler.swcify(ctx),
314            finalizer: self.finalizer.swcify(ctx),
315        }
316    }
317}
318
319impl Swcify for swc_estree_ast::CatchClause {
320    type Output = swc_ecma_ast::CatchClause;
321
322    fn swcify(self, ctx: &Context) -> Self::Output {
323        swc_ecma_ast::CatchClause {
324            span: ctx.span(&self.base),
325            param: self.param.swcify(ctx),
326            body: self.body.swcify(ctx),
327        }
328    }
329}
330
331impl Swcify for swc_estree_ast::CatchClauseParam {
332    type Output = Pat;
333
334    fn swcify(self, ctx: &Context) -> Self::Output {
335        match self {
336            swc_estree_ast::CatchClauseParam::Id(v) => v.swcify(ctx).into(),
337            swc_estree_ast::CatchClauseParam::Array(v) => v.swcify(ctx).into(),
338            swc_estree_ast::CatchClauseParam::Object(v) => v.swcify(ctx).into(),
339        }
340    }
341}
342
343impl Swcify for VariableDeclaration {
344    type Output = VarDecl;
345
346    fn swcify(self, ctx: &Context) -> Self::Output {
347        VarDecl {
348            span: ctx.span(&self.base),
349            kind: match self.kind {
350                VariableDeclarationKind::Var => VarDeclKind::Var,
351                VariableDeclarationKind::Let => VarDeclKind::Let,
352                VariableDeclarationKind::Const => VarDeclKind::Const,
353            },
354            declare: self.declare.unwrap_or_default(),
355            decls: self.declarations.swcify(ctx),
356            ..Default::default()
357        }
358    }
359}
360
361impl Swcify for VariableDeclarator {
362    type Output = VarDeclarator;
363
364    fn swcify(self, ctx: &Context) -> Self::Output {
365        VarDeclarator {
366            span: ctx.span(&self.base),
367            name: self.id.swcify(ctx),
368            init: self.init.swcify(ctx),
369            definite: self.definite.unwrap_or_default(),
370        }
371    }
372}
373
374impl Swcify for WhileStatement {
375    type Output = WhileStmt;
376
377    fn swcify(self, ctx: &Context) -> Self::Output {
378        WhileStmt {
379            span: ctx.span(&self.base),
380            test: self.test.swcify(ctx),
381            body: Box::new(self.body.swcify(ctx).expect_stmt()),
382        }
383    }
384}
385
386impl Swcify for WithStatement {
387    type Output = WithStmt;
388
389    fn swcify(self, ctx: &Context) -> Self::Output {
390        WithStmt {
391            span: ctx.span(&self.base),
392            obj: self.object.swcify(ctx),
393            body: Box::new(self.body.swcify(ctx).expect_stmt()),
394        }
395    }
396}
397
398impl Swcify for ClassDeclaration {
399    type Output = ClassDecl;
400
401    fn swcify(self, ctx: &Context) -> Self::Output {
402        ClassDecl {
403            ident: self.id.swcify(ctx).into(),
404            declare: self.declare.unwrap_or_default(),
405            class: swc_ecma_ast::Class {
406                span: ctx.span(&self.base),
407                decorators: self.decorators.swcify(ctx).unwrap_or_default(),
408                body: self.body.swcify(ctx),
409                super_class: self.super_class.swcify(ctx),
410                is_abstract: self.is_abstract.unwrap_or_default(),
411                ..Default::default()
412            }
413            .into(),
414        }
415    }
416}
417
418impl Swcify for ExportAllDeclaration {
419    type Output = ExportAll;
420
421    fn swcify(self, ctx: &Context) -> Self::Output {
422        ExportAll {
423            span: ctx.span(&self.base),
424            src: self.source.swcify(ctx).into(),
425            type_only: self.export_kind == Some(ExportKind::Type),
426            with: self
427                .with
428                .swcify(ctx)
429                .map(|props| {
430                    props
431                        .into_iter()
432                        .map(Prop::KeyValue)
433                        .map(Box::new)
434                        .map(PropOrSpread::Prop)
435                        .collect()
436                })
437                .map(|props| {
438                    ObjectLit {
439                        span: DUMMY_SP,
440                        props,
441                    }
442                    .into()
443                }),
444        }
445    }
446}
447
448impl Swcify for ImportAttribute {
449    type Output = KeyValueProp;
450
451    fn swcify(self, ctx: &Context) -> Self::Output {
452        KeyValueProp {
453            key: self.key.swcify(ctx),
454            value: Lit::Str(self.value.swcify(ctx)).into(),
455        }
456    }
457}
458
459impl Swcify for IdOrString {
460    type Output = PropName;
461
462    fn swcify(self, ctx: &Context) -> Self::Output {
463        match self {
464            IdOrString::Id(v) => PropName::Ident(v.swcify(ctx).into()),
465            IdOrString::String(v) => PropName::Str(v.swcify(ctx)),
466        }
467    }
468}
469
470impl Swcify for ExportDefaultDeclaration {
471    type Output = ModuleDecl;
472
473    fn swcify(self, ctx: &Context) -> Self::Output {
474        match self.declaration {
475            ExportDefaultDeclType::Func(v) => {
476                let d = v.swcify(ctx);
477                ExportDefaultDecl {
478                    span: ctx.span(&self.base),
479                    decl: DefaultDecl::Fn(FnExpr {
480                        ident: Some(d.ident),
481                        function: d.function,
482                    }),
483                }
484                .into()
485            }
486            ExportDefaultDeclType::Class(v) => {
487                let d = v.swcify(ctx);
488                ExportDefaultDecl {
489                    span: ctx.span(&self.base),
490                    decl: DefaultDecl::Class(ClassExpr {
491                        ident: Some(d.ident),
492                        class: d.class,
493                    }),
494                }
495                .into()
496            }
497            ExportDefaultDeclType::Expr(v) => ExportDefaultExpr {
498                span: ctx.span(&self.base),
499                expr: v.swcify(ctx),
500            }
501            .into(),
502            _ => {
503                todo!("swcify: {:?}", self)
504            }
505        }
506    }
507}
508
509impl Swcify for ExportNamedDeclaration {
510    type Output = NamedExport;
511
512    fn swcify(self, ctx: &Context) -> Self::Output {
513        NamedExport {
514            span: ctx.span(&self.base),
515            specifiers: self.specifiers.swcify(ctx),
516            src: self.source.swcify(ctx).map(Box::new),
517            type_only: false,
518            with: self
519                .with
520                .swcify(ctx)
521                .map(|props| {
522                    props
523                        .into_iter()
524                        .map(Prop::KeyValue)
525                        .map(Box::new)
526                        .map(PropOrSpread::Prop)
527                        .collect()
528                })
529                .map(|props| {
530                    ObjectLit {
531                        span: DUMMY_SP,
532                        props,
533                    }
534                    .into()
535                }),
536        }
537    }
538}
539
540impl Swcify for swc_estree_ast::ExportSpecifierType {
541    type Output = swc_ecma_ast::ExportSpecifier;
542
543    fn swcify(self, ctx: &Context) -> Self::Output {
544        match self {
545            swc_estree_ast::ExportSpecifierType::Export(v) => {
546                swc_ecma_ast::ExportSpecifier::from(v.swcify(ctx))
547            }
548            swc_estree_ast::ExportSpecifierType::Default(v) => {
549                swc_ecma_ast::ExportSpecifier::from(v.swcify(ctx))
550            }
551            swc_estree_ast::ExportSpecifierType::Namespace(v) => {
552                swc_ecma_ast::ExportSpecifier::from(v.swcify(ctx))
553            }
554        }
555    }
556}
557
558impl Swcify for swc_estree_ast::ExportSpecifier {
559    type Output = ExportNamedSpecifier;
560
561    fn swcify(self, ctx: &Context) -> Self::Output {
562        ExportNamedSpecifier {
563            span: ctx.span(&self.base),
564            orig: self.local.swcify(ctx),
565            exported: Some(self.exported.swcify(ctx)),
566            is_type_only: matches!(self.export_kind, ExportKind::Type),
567        }
568    }
569}
570
571impl Swcify for swc_estree_ast::ExportDefaultSpecifier {
572    type Output = swc_ecma_ast::ExportDefaultSpecifier;
573
574    fn swcify(self, ctx: &Context) -> Self::Output {
575        swc_ecma_ast::ExportDefaultSpecifier {
576            exported: self.exported.swcify(ctx).into(),
577        }
578    }
579}
580
581impl Swcify for swc_estree_ast::ExportNamespaceSpecifier {
582    type Output = swc_ecma_ast::ExportNamespaceSpecifier;
583
584    fn swcify(self, ctx: &Context) -> Self::Output {
585        swc_ecma_ast::ExportNamespaceSpecifier {
586            span: ctx.span(&self.base),
587            name: self.exported.swcify(ctx),
588        }
589    }
590}
591
592impl Swcify for ForOfStatement {
593    type Output = ForOfStmt;
594
595    fn swcify(self, ctx: &Context) -> Self::Output {
596        ForOfStmt {
597            span: ctx.span(&self.base),
598            is_await: false,
599            left: self.left.swcify(ctx),
600            right: self.right.swcify(ctx),
601            body: Box::new(self.body.swcify(ctx).expect_stmt()),
602        }
603    }
604}
605
606impl Swcify for ImportDeclaration {
607    type Output = ImportDecl;
608
609    fn swcify(self, ctx: &Context) -> Self::Output {
610        ImportDecl {
611            span: ctx.span(&self.base),
612            specifiers: self.specifiers.swcify(ctx),
613            src: self.source.swcify(ctx).into(),
614            type_only: false,
615            with: self
616                .with
617                .swcify(ctx)
618                .map(|props| {
619                    props
620                        .into_iter()
621                        .map(Prop::KeyValue)
622                        .map(Box::new)
623                        .map(PropOrSpread::Prop)
624                        .collect()
625                })
626                .map(|props| {
627                    ObjectLit {
628                        span: DUMMY_SP,
629                        props,
630                    }
631                    .into()
632                }),
633            phase: self
634                .phase
635                .map(|phase| Swcify::swcify(phase, ctx))
636                .unwrap_or_default(),
637        }
638    }
639}
640
641impl Swcify for swc_estree_ast::ImportPhase {
642    type Output = swc_ecma_ast::ImportPhase;
643
644    fn swcify(self, _: &Context) -> Self::Output {
645        match self {
646            Self::Source => Self::Output::Source,
647            Self::Defer => Self::Output::Defer,
648        }
649    }
650}
651
652impl Swcify for ImportSpecifierType {
653    type Output = ImportSpecifier;
654
655    fn swcify(self, ctx: &Context) -> Self::Output {
656        match self {
657            ImportSpecifierType::Import(v) => v.swcify(ctx).into(),
658            ImportSpecifierType::Default(v) => v.swcify(ctx).into(),
659            ImportSpecifierType::Namespace(v) => v.swcify(ctx).into(),
660        }
661    }
662}
663
664impl Swcify for swc_estree_ast::ModuleExportNameType {
665    type Output = swc_ecma_ast::ModuleExportName;
666
667    fn swcify(self, ctx: &Context) -> Self::Output {
668        match self {
669            swc_estree_ast::ModuleExportNameType::Ident(ident) => {
670                swc_ecma_ast::ModuleExportName::Ident(ident.swcify(ctx).into())
671            }
672            swc_estree_ast::ModuleExportNameType::Str(s) => s.swcify(ctx).into(),
673        }
674    }
675}
676
677impl Swcify for swc_estree_ast::ImportSpecifier {
678    type Output = ImportNamedSpecifier;
679
680    fn swcify(self, ctx: &Context) -> Self::Output {
681        ImportNamedSpecifier {
682            span: ctx.span(&self.base),
683            local: self.local.swcify(ctx).into(),
684            imported: Some(self.imported.swcify(ctx)),
685            is_type_only: matches!(self.import_kind, Some(ImportKind::Type)),
686        }
687    }
688}
689
690impl Swcify for swc_estree_ast::ImportDefaultSpecifier {
691    type Output = swc_ecma_ast::ImportDefaultSpecifier;
692
693    fn swcify(self, ctx: &Context) -> Self::Output {
694        swc_ecma_ast::ImportDefaultSpecifier {
695            span: ctx.span(&self.base),
696            local: self.local.swcify(ctx).into(),
697        }
698    }
699}
700
701impl Swcify for ImportNamespaceSpecifier {
702    type Output = ImportStarAsSpecifier;
703
704    fn swcify(self, ctx: &Context) -> Self::Output {
705        ImportStarAsSpecifier {
706            span: ctx.span(&self.base),
707            local: self.local.swcify(ctx).into(),
708        }
709    }
710}
711
712impl Swcify for DeclareClass {
713    type Output = ClassDecl;
714
715    fn swcify(self, _: &Context) -> Self::Output {
716        unimplemented!("flow")
717    }
718}
719
720impl Swcify for DeclareFunction {
721    type Output = FnDecl;
722
723    fn swcify(self, _: &Context) -> Self::Output {
724        unimplemented!("flow")
725    }
726}
727
728impl Swcify for DeclareInterface {
729    type Output = TsInterfaceDecl;
730
731    fn swcify(self, _: &Context) -> Self::Output {
732        unimplemented!("flow")
733    }
734}
735
736impl Swcify for DeclareModule {
737    type Output = TsModuleDecl;
738
739    fn swcify(self, _: &Context) -> Self::Output {
740        unimplemented!("flow")
741    }
742}
743
744impl Swcify for DeclareModuleExports {
745    type Output = TsExportAssignment;
746
747    fn swcify(self, _: &Context) -> Self::Output {
748        unimplemented!("flow")
749    }
750}
751
752impl Swcify for DeclareTypeAlias {
753    type Output = TsTypeAliasDecl;
754
755    fn swcify(self, _: &Context) -> Self::Output {
756        unimplemented!("flow")
757    }
758}
759
760impl Swcify for DeclareVariable {
761    type Output = VarDecl;
762
763    fn swcify(self, _: &Context) -> Self::Output {
764        unimplemented!("flow")
765    }
766}
767
768impl Swcify for DeclareExportDeclaration {
769    type Output = ExportDecl;
770
771    fn swcify(self, _: &Context) -> Self::Output {
772        unimplemented!("flow")
773    }
774}
775
776impl Swcify for DeclareExportAllDeclaration {
777    type Output = ExportAll;
778
779    fn swcify(self, ctx: &Context) -> Self::Output {
780        ExportAll {
781            span: ctx.span(&self.base),
782            src: self.source.swcify(ctx).into(),
783            type_only: self.export_kind == Some(ExportKind::Type),
784            with: Default::default(),
785        }
786    }
787}