There exists a type similar to the following:
export type PathType =
| LivingstoneSouthernWhiteFacedOwl
| ArakGroundhog
| HubsCampaigns
| HubsCampaignsItemID
| HubsAlgos
| HubsAlgosItemID
| TartuGecko
| HammerfestPonies
| TrapaniSnowLeopard
| BeijingPigeon
| Link
| LinksMhdSwsVisordeltas
| MetadatahandlingName
| MetadatahandlingGetmetadataSequencesNameSequenceNameLabelNameLabelName;
These represent interfaces of open API definition paths.
My task is to create a function like this one:
import { PathType } from '../types/path.type';
const makeFormJSONSchema = (path: PathType) => {
const schema = {};
// 1. If there are any `parameters`, include them in the schema
if (path.hasOwnProperty('parameters')) {
path.parameters;
}
// 2. Peek at the method object using the `method` property
// 3. Check for additional `parameters` and add them to the schema
// 4. Check for `requestBody` and include it in the schema
return schema;
};
export default makeFormJSONSchema;
In the code, I check if the path
object has the parameters
property, then attempt to access it.
However, TypeScript throws an error as shown here.
How can we inform TypeScript that we indeed have this property?