in src/utils/getTSType.ts [172:247]
key: getTSTypeWithResolvedTypes(
param.get('parameters').get(0).get('typeAnnotation'),
typeParams,
importer,
),
value: getTSTypeWithRequirements(
param.get('typeAnnotation'),
typeParams,
importer,
),
});
}
});
return type;
}
function handleTSInterfaceDeclaration(path: NodePath): SimpleType {
// Interfaces are handled like references which would be documented separately,
// rather than inlined like type aliases.
return {
name: path.node.id.name,
};
}
function handleTSUnionType(
path: NodePath,
typeParams: TypeParameters | null,
importer: Importer,
): ElementsType<TSFunctionSignatureType> {
return {
name: 'union',
raw: printValue(path),
elements: path
.get('types')
.map(subType =>
getTSTypeWithResolvedTypes(subType, typeParams, importer),
),
};
}
function handleTSIntersectionType(
path: NodePath,
typeParams: TypeParameters | null,
importer: Importer,
): ElementsType<TSFunctionSignatureType> {
return {
name: 'intersection',
raw: printValue(path),
elements: path
.get('types')
.map(subType =>
getTSTypeWithResolvedTypes(subType, typeParams, importer),
),
};
}
function handleTSMappedType(
path: NodePath,
typeParams: TypeParameters | null,
importer: Importer,
): ObjectSignatureType<TSFunctionSignatureType> {
const key = getTSTypeWithResolvedTypes(
path.get('typeParameter').get('constraint'),
typeParams,
importer,
);
key.required = !path.node.optional;
return {
name: 'signature',
type: 'object',
raw: printValue(path),
signature: {
properties: [
{