How to use the isExportDeclaration function from @babel/types

Find comprehensive JavaScript @babel/types.isExportDeclaration code examples handpicked from public code repositorys.

121
122
123
124
125
126
127
128
129
130
// If no exports detected in the file after CC, add `export {}` to bypass --isolatedModules check
Program: {
  exit(path) {
    let hasExport = false;
    path.node.body.forEach(node => {
      hasExport = hasExport || t.isExportDeclaration(node);
    });
    if (!hasExport) {
      const exportNode = t.exportNamedDeclaration();
      t.addComment(exportNode, 'trailing', 'The above line is generated by conditional compilation, when no export detected after CC.');
fork icon37
star icon93
watch icon129

+ 6 other calls in file

190
191
192
193
194
195
196
197
198
199
}

function isExport(node) {
        return (
                t.isExportAllDeclaration(node) ||
                t.isExportDeclaration(node) ||
                t.isExportDefaultDeclaration(node) ||
                t.isExportNamedDeclaration(node) ||
                t.isExportNamespaceSpecifier(node)
        );
fork icon2
star icon35
watch icon2

+ 33 other calls in file

21
22
23
24
25
26
27
28
29
30
31


// Gets component name from export declaration. Expects a File node
module.exports = function({ syntaxTree }) {
  const exportDeclarations = syntaxTree.program.body.filter(
    statement =>
      t.isExportDeclaration(statement) &&
      !t.isTSInterfaceDeclaration(statement.declaration) &&
      !t.isTSTypeAliasDeclaration(statement.declaration)
  );

fork icon2
star icon1
watch icon0

175
176
177
178
179
180
181
182
183
184
185
186
    exportDefault: true
  });
}


function ArrowFunctionExpression(node, parent) {
  return t.isExportDeclaration(parent) || ConditionalExpression(node, parent);
}


function ConditionalExpression(node, parent) {
  if (t.isUnaryLike(parent) || t.isBinary(parent) || t.isConditionalExpression(parent, {
fork icon0
star icon0
watch icon0

+ 2 other calls in file

Other functions in @babel/types

Sorted by popularity

function icon

@babel/types.identifier is the most popular function in @babel/types (20936 examples)