How to use the assertIdentifier function from @babel/types

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

7
8
9
10
11
12
13
14
15
16
module.exports = function normalizeArguments(use) {
  return use.parentPath.get('arguments').flatMap(argPath => {
    const arg = argPath.node;
    if (t.isObjectExpression(arg)) {
      return arg.properties.map(prop => {
        t.assertIdentifier(prop.key);

        return {
          test: extractNode(use, prop.value),
          value: prop.key.name
fork icon18
star icon195
watch icon7

+ 5 other calls in file

100
101
102
103
104
105
106
107
108
109
    "  const src = fs.readFileSync(path.join(__dirname, 'foo.txt'));\n");
}

function extractRequiredModule (node) {
  t.assertCallExpression(node);
  t.assertIdentifier(node.callee, { name: 'require' });
  var arg = node.arguments[0];
  t.assertStringLiteral(arg);
  return arg.value;
}
fork icon11
star icon33
watch icon8

+ 13 other calls in file

57
58
59
60
61
62
63
64
65
66
  t.assertIdentifier(firstType.ref(), { name: firstType.graphqlName });

  typeMap.addSwaggerDefinition(SIMPLE_OBJ, 'My.Type.bar');
  const colliding = typeMap.getBySwaggerName('My.Type.bar');
  assert.equal('MyTypeBar2', colliding.graphqlName);
  t.assertIdentifier(colliding.ref(), { name: colliding.graphqlName });
});

it('can handle recursive lists', () => {
  const builtIn = new BuiltInTypes();
fork icon3
star icon46
watch icon11

+ 17 other calls in file

55
56
57
58
59
60
61
62
63
64
  AConnectionType,
  BConnectionType
);

t.assertIdentifier(AConnectionType, { name: 'AConnection' });
t.assertIdentifier(BConnectionType, { name: 'BConnection' });

const AConnectionAST = typeMap.getBySwaggerName('AConnection').ast;
const AEdgeAST = typeMap.getBySwaggerName('AEdge').ast;
assert.equal(
fork icon3
star icon46
watch icon11

+ 3 other calls in file

29
30
31
32
33
34
35
36
37
38
});

it('returns identifiers for referenced types', () => {
  const builtIn = new BuiltInTypes();
  const ref = builtIn.ref('GraphQLBoolean');
  t.assertIdentifier(ref, { name: 'GraphQLBoolean' });
});

it('supports swagger-style refs', () => {
  const builtIn = new BuiltInTypes();
fork icon3
star icon46
watch icon11

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