Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const fragmentSpreadSuperClasses = (fragmentSpreads || []).filter(spread => {
const fragment = generator.context.fragments[spread];
const alwaysDefined = isTypeProperSuperTypeOf(
generator.context.schema,
fragment.typeCondition,
parentType
);
return alwaysDefined;
});
fragmentSpreads.forEach(s => {
const fragment = generator.context.fragments[s];
const alwaysDefined = isTypeProperSuperTypeOf(
generator.context.schema,
fragment.typeCondition,
parentType
);
if (!alwaysDefined) {
generator.printOnNewline(`def as${s}`);
generator.print(`: Option[${s}] =`);
generator.withinBlock(() => {
generator.printOnNewline(
`if (${s}.possibleTypes.contains(orig.asInstanceOf[scala.scalajs.js.Dynamic].__typename.asInstanceOf[String])) Some(orig.asInstanceOf[${s}]) else None`
);
});
}
});
}