function createDuplicateEnumValuesCheck()

in src/transforms/deprecation-warnings.ts [696:732]


function createDuplicateEnumValuesCheck(type: spec.TypeBase & spec.EnumType): ts.Statement {
  return ts.factory.createIfStatement(
    ts.factory.createBinaryExpression(
      ts.factory.createPropertyAccessExpression(
        ts.factory.createCallExpression(
          ts.factory.createPropertyAccessExpression(
            ts.factory.createCallExpression(
              ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('Object'), 'values'),
              undefined,
              [ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(LOCAL_ENUM_NAMESPACE), type.name)],
            ),
            ts.factory.createIdentifier('filter'),
          ),
          undefined,
          [
            ts.factory.createArrowFunction(
              undefined,
              undefined,
              [ts.factory.createParameterDeclaration(undefined, undefined, 'x')],
              undefined,
              ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
              ts.factory.createBinaryExpression(
                ts.factory.createIdentifier('x'),
                ts.factory.createToken(ts.SyntaxKind.EqualsEqualsEqualsToken),
                ts.factory.createIdentifier(PARAMETER_NAME),
              ),
            ),
          ],
        ),
        ts.factory.createIdentifier('length'),
      ),
      ts.factory.createToken(ts.SyntaxKind.GreaterThanToken),
      ts.factory.createNumericLiteral('1'),
    ),
    ts.factory.createReturnStatement(),
  );
}