How to use the isTSTypeAliasDeclaration function from @babel/types

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

41
42
43
44
45
46
47
48
49
50
    }
    if (node.abstract) {
      comment.abstract = true;
    }
  }
} else if (t.isTypeAlias(node) || t.isTSTypeAliasDeclaration(node)) {
  comment.kind = 'typedef';
} else if (
  t.isInterfaceDeclaration(node) ||
  t.isTSInterfaceDeclaration(node)
fork icon509
star icon0
watch icon0

+ 20 other calls in file

188
189
190
191
192
193
194
195
196
197
} else if (
  t.isClassDeclaration(declaration) ||
  t.isFunctionDeclaration(declaration) ||
  t.isTypeAlias(declaration) ||
  t.isInterfaceDeclaration(declaration) ||
  t.isTSTypeAliasDeclaration(declaration) ||
  t.isTSInterfaceDeclaration(declaration) ||
  t.isTSEnumDeclaration(declaration) ||
  t.isTSDeclareFunction(declaration) ||
  t.isTSDeclareMethod(declaration)
fork icon6
star icon34
watch icon0

+ 3 other calls in file

47
48
49
50
51
52
53
54
55
56
try {
  const parseResult = /** @type {babel.types.File} */ (
    parse(`type X = ${code}`, { plugins: ['typescript'] })
  );
  const { body } = parseResult.program;
  return t.isTSTypeAliasDeclaration(body[0])
    ? body[0].typeAnnotation
    : t.tsUnknownKeyword();
} catch (err) {
  debug(`Failed to parse type string "${code}"`, err);
fork icon0
star icon0
watch icon7

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