How to use the tsLiteralType function from @babel/types

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

36
37
38
39
40
41
42
43
44
45
  return t.tsTypeLiteral(properties);
},
string(schema) {
  if (schema.enum) {
    return t.tsUnionType(
      schema.enum.map((variant) => t.tsLiteralType(t.stringLiteral(variant))),
    );
  }
  return t.tsStringKeyword();
  // add enum
fork icon2
star icon14
watch icon2

+ 23 other calls in file

70
71
72
73
74
75
76
77
78
79
return t.tsTypeLiteral(
  Object.keys(value).map(key => {
    let propertyValue = value[key];
    let propertyValueType =
      path.length === 0 && key === 'environment'
        ? t.tsLiteralType(t.stringLiteral(propertyValue))
        : typeFor(path.concat(key), propertyValue);

    return t.tsPropertySignature(t.identifier(key), t.tsTypeAnnotation(propertyValueType));
  })
fork icon0
star icon1
watch icon0

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