How to use the isSpreadElement function from @babel/types

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

168
169
170
171
172
173
174
175
176

const getObjectDescriptor = async ({ node, ast, cwd }) => {
  const scopedAst = node.ast || ast;
  const scopedCwd = node.cwd || cwd;
  const methodPromises = node.properties.map(node =>
    types.isSpreadElement(node)
      ? getSpreadDescriptor({ node: node.argument, ast: scopedAst, cwd: scopedCwd })
      : getPropertyDescriptor({ node: node, ast: scopedAst, cwd: scopedCwd })
  );
fork icon2
star icon11
watch icon222

+ 3 other calls in file

18
19
20
21
22
23
24
25
26
27
  input: transformInput,
  text: transformTextBlock
};

function transformNode(element, scope) {
  if (t.isExpression(element) || t.isSpreadElement(element) || t.isIdentifier(element)) {
    return element;
  }
  const objectExpression = t.objectExpression([]);
  const ast = nodeKindTransformMap[element.$$kind](element, scope);
fork icon0
star icon9
watch icon2

+ 3 other calls in file

18
19
20
21
22
23
24
25
26
27
28
 * @param {SpreadElement | ObjectProperty} prop2
 * @returns {number}
 */
function objectPropertyComparator(prop1, prop2) {
  const isProp1Spread = types.isSpreadElement(prop1);
  const isProp2Spread = types.isSpreadElement(prop2);


  // if both are SpreadElements, keep the order they came in
  if (isProp1Spread || isProp2Spread) {
    return 0;
fork icon0
star icon0
watch icon0

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