| Error | Explanation | Why it Happens | How to Fix |
|---|---|---|---|
Module '"../types"' has no exported member 'ApplyPromoResult'. |
TypeScript cannot find ApplyPromoResult in your types module. |
You either didn’t define it, or didn’t export it from your types/index.ts. |
Create ApplyPromoResult in a file (e.g., carts-inputs.ts) and export it in index.ts. Example: typescript <br> export type ApplyPromoResult = { <br> success: boolean; <br> discountAmount?: number; <br> message?: string; <br> }; <br> |
The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. 'flashPrice' is possibly 'null'. |
TypeScript is complaining that flashPrice might be null and you’re trying to multiply it with item.quantity. |
TypeScript is strict about null or undefined values in arithmetic operations. |
Ensure flashPrice is always a number. Use a null check: typescript <br> const price = flashPrice ?? 0; <br> newTotal += price * item.quantity; <br> |
Property 'cart' does not exist on type '{ quantity: number; }'. |
You are trying to access item.cart but TypeScript thinks item has no cart property. |
Either the type of item is wrong, or cart is optional/missing in the type. |
Fix the type definition of item so cart exists, or add a safety check: typescript <br> item.cart?.status === 'COMPLETED' <br> |
Module '"./promo-codes"' declares 'DiscountType' locally, but it is not exported. |
TypeScript sees DiscountType in promo-codes.ts, but it is not exported, so your index.ts cannot re-export it. |
You imported it from Prisma but forgot to export it in promo-codes.ts. |
In promo-codes.ts, export it explicitly: typescript <br> export { DiscountType }; <br> |
Module '"../types"' has no exported member ... (other cart types) |
Same as the first error, TypeScript cannot find CreateCartInput, UpdateCartInput, etc. |
You didn’t define or export these types in your types/index.ts. |
Define each type in a file (like carts-inputs.ts) and export them via index.ts. |
Written by A.M. Rinas