medusajs / medusa

Building blocks for digital commerce
https://medusajs.com
MIT License
24.45k stars 2.4k forks source link

Error when extending MoneyAmount repository #6605

Open kjedras opened 6 months ago

kjedras commented 6 months ago

Describe the bug

Im writing a plugin, and as a part of the plugin i need to extend MoneyAmount repository. Whenever i run the build command i get an error saying

Exported variable 'MoneyAmountRepository' has or is using name '_QueryDeepPartialEntity' from external module "(path)/node_modules/typeorm/query-builder/QueryPartialEntity" but cannot be named

I've tried importing QueryDeepPartialEntity: import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity"; but it didn't help.

I did not extend MoneyAmount model so i didn't include { target: MoneyAmount }. I've tried including it but the same error still occurred.

System information

Medusa version (including plugins): 1.20 Node.js version: 18.8.0 Database: Postgres Operating system: Windows 10

Code snippets

import {
  MoneyAmount,
  ProductVariant,
  ProductVariantMoneyAmount,
} from "@medusajs/medusa";
import { dataSource } from "@medusajs/medusa/dist/loaders/database";
import { MoneyAmountRepository as MedusaMoneyAmountRepository } from "@medusajs/medusa/dist/repositories/money-amount";
import { groupBy } from "lodash";
import { Brackets } from "typeorm";

export const MoneyAmountRepository = dataSource
  .getRepository(MoneyAmount)
  .extend(
    Object.assign(MedusaMoneyAmountRepository, {
      customFunction(): void {
        console.log("test");
      },
    })
  );

export default MoneyAmountRepository;
haiderchristoph commented 4 months ago

@kjedras did you find a solution to this? I'm running into the same problem