TS4055

Return type of public method from exported class has or is using private name PortfolioOpenPositionSchema.

Broken Code ❌

const PortfolioOpenPositionSchema = z.object({
  averagePrice: z.number(),
  currentPrice: z.number(),
  frontend: z.string(),
  fxPpl: z.number(),
  initialFillDate: z.string(),
  maxBuy: z.number(),
  maxSell: z.number(),
  pieQuantity: z.number(),
  ppl: z.number(),
  quantity: z.number(),
  ticker: z.string(),
});
 
async getOpenPosition(ticker: string): Promise<PortfolioOpenPositionSchema>;

Solution:

Change the method's return type to use the exported type PortfolioOpenPosition instead of the non-exported schema object.

Fixed Code ✔️

const PortfolioOpenPositionSchema = z.object({
  averagePrice: z.number(),
  currentPrice: z.number(),
  frontend: z.string(),
  fxPpl: z.number(),
  initialFillDate: z.string(),
  maxBuy: z.number(),
  maxSell: z.number(),
  pieQuantity: z.number(),
  ppl: z.number(),
  quantity: z.number(),
  ticker: z.string(),
});
 
export type PortfolioOpenPosition = z.infer<typeof PortfolioOpenPositionSchema>;
 
async getOpenPosition(ticker: string): Promise<PortfolioOpenPosition>;