How to use the typeAnnotation function from @babel/types

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

7
8
9
10
11
12
13
14
15
    if (!path.node.returnType) {
      warnings.push({
        info: `Found function without return type, using number as default`,
        loc: path.container.loc,
      });
      path.node.returnType = t.typeAnnotation(t.numberTypeAnnotation());
    }
  }
});
fork icon4
star icon20
watch icon2

+ 3 other calls in file

124
125
126
127
128
129
130
131
132
133
const optional = generateOptionalParam(details.optionalArgs);
const createType = (req) =>
  t.declareExportDeclaration(
    t.declareFunction({
      ...t.identifier(details.name),
      typeAnnotation: t.typeAnnotation(
        t.functionTypeAnnotation(
          null,
          req.concat(optional),
          null,
fork icon1
star icon3
watch icon2

+ 30 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)