How to use the unionTypeAnnotation function from babel-types
Find comprehensive JavaScript babel-types.unionTypeAnnotation code examples handpicked from public code repositorys.
31 32 33 34 35 36 37 38 39 40
}; function buildType(syntax, key) { if (syntax.type === 'Sequence') { let types = syntax.terms.map(p => buildType(p, key)); return t.unionTypeAnnotation(types); } else if (syntax.type === 'Keyword') { return t.stringLiteral(syntax.name); } else if (syntax.type === 'Function') { return t.identifier('string');
10
148
8
+ 5 other calls in file
87 88 89 90 91 92 93 94 95 96
function unionTypeAnnotation(types: Array<BabelAST>): BabelAST { invariant( types.length > 0, 'RelayFlowBabelFactories: cannot create a union of 0 types', ); return types.length === 1 ? types[0] : t.unionTypeAnnotation(types); } module.exports = { exactObjectTypeAnnotation,
0
1
3
+ 5 other calls in file
152 153 154 155 156 157 158 159 160 161
if (!types.length) { return exactObjectTypeAnnotation([]); } return types.length > 1 ? t.unionTypeAnnotation(types) : types[0]; } function lineComments(...lines: Array<string>) { return lines.map(line => ({type: 'CommentLine', value: ' ' + line}));
0
1
2
babel-types.identifier is the most popular function in babel-types (4076 examples)