in src/rule-generated-flow-types.js [81:148]
function getPropTypeProperty(
context,
typeAliasMap,
propType,
propName,
visitedProps = new Set()
) {
if (propType == null || visitedProps.has(propType)) {
return null;
}
visitedProps.add(propType);
const spreadsToVisit = [];
if (propType.type === 'GenericTypeAnnotation') {
return getPropTypeProperty(
context,
typeAliasMap,
extractReadOnlyType(resolveTypeAlias(propType, typeAliasMap)),
propName,
visitedProps
);
}
if (propType.type !== 'ObjectTypeAnnotation') {
return null;
}
for (const property of propType.properties) {
if (property.type === 'ObjectTypeSpreadProperty') {
spreadsToVisit.push(property);
} else {
// HACK: Type annotations don't currently expose a 'key' property:
// https://github.com/babel/babel-eslint/issues/307
let tokenIndex = 0;
if (property.static) {
tokenIndex++;
}
if (property.variance) {
tokenIndex++;
}
if (
context.getSourceCode().getFirstToken(property, tokenIndex).value ===
propName
) {
return property;
}
}
}
for (const property of spreadsToVisit) {
if (
property.argument &&
property.argument.id &&
property.argument.id.name
) {
const nextPropType = typeAliasMap[property.argument.id.name];
const result = getPropTypeProperty(
context,
typeAliasMap,
nextPropType,
propName,
visitedProps
);
if (result) {
return result;
}
}
}
return null;
}