cds-typer icon indicating copy to clipboard operation
cds-typer copied to clipboard

[BUG] Error "... has no exported member ..." in generated code

Open mcastrup opened this issue 2 years ago • 6 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Nature of Your Project

TypeScript

Current Behavior

In one of the generated files, there are two errors regarding the import and usage of "Currencies":

image

Error message: '"c:/Users/D048091/git/crypto-for-business/@cds-models/sap/common/index"' has no exported member named 'Currencies'. Did you mean 'Currency'?

The code can be also seen in this file:

export function _FiatCurrencyAspect<TBase extends new (...args: any[]) => object>(Base: TBase) {
  return class FiatCurrency extends Base {
        name?: string | null;
        descr?: string | null;
        code?: string;
        symbol?: string | null;
        minorUnit?: number | null;
        texts?: __.Composition.of.many<_sap_common.Currencies.texts>;
        localized?: __.Association.to<_sap_common.Currencies.text> | null;
    /**
    * Type for a language code
    */
        localized_locale?: _sap_common.Locale | null;
        localized_code?: string | null;
      static actions: {
    }
  };
}

The related entity to the FiatCurrency class is:

using {sap.common.Currencies} from '@sap/cds-common-content';

namespace sap.erp4sme.c4b.payment.fiatCurrencies;

@cds.persistence.skip: false
entity FiatCurrencies as select from Currencies;

See also this file.

Expected Behavior

I'm not sure what is the correct code. Of course, there should be no errors.

Steps To Reproduce

You can clone our repository crypto-for-business locally with git clone https://github.tools.sap/erp4sme/crypto-for-business.git, checkout the branch switch_to_typer_prototype and run npm ci and npm run cds-typer:dev

Environment

- **OS**: Windows
- **Node**: v18.13.0
- **npm**: 8.19.3
- **cds-typer**: 0.15.0
- **cds**: 7.4.1

Repository Containing a Minimal Reproducible Example

No response

Anything else?

No response

mcastrup avatar Jan 17 '24 11:01 mcastrup

Is the issue fixed if you import sap.common.Currencies from @sap/cds/common instead of @sap/cds-common-content? The definition will be the same.

hakimio avatar Jan 17 '24 12:01 hakimio

Hi @hakimio I changed the import as you suggested to using {sap.common.Currencies} from '@sap/cds/common'; However, the error still exists.

mcastrup avatar Jan 17 '24 13:01 mcastrup

Hi Michael,

this issue is actually closely related to https://github.com/cap-js/cds-typer/issues/77

Localisation and text properties are not supported by cds-typer at this point in time. So it is to be expected that their type is incorrect. I am more suprised that cds-typer attempts to generate them regardless, as we are currently skipping them. I will look into it.

Best, Daniel

daogrady avatar Jan 17 '24 14:01 daogrady

Hi Daniel,

do you have an idea, when this issue will be fixed? It currently blockes our build process.

Thanks and best regards, Michael

mcastrup avatar Jan 29 '24 11:01 mcastrup

Hi Michael,

sorry, I am afraid not any time soon from my side, as I have to prioritise another project for an upcoming release. If you would like to submit a PR to address the problem, I will make sure to carve out some time to review it to make sure the issue is fixed asap.

Best Daniel

daogrady avatar Jan 29 '24 12:01 daogrady

This issue has not been updated in a while. If it is still relevant, please comment on it to keep it open. The issue will be closed soon if it remains inactive.

github-actions[bot] avatar Feb 28 '24 18:02 github-actions[bot]

Hi Michael,

I just re-checked your issue and this is addressed as of 0.32.1. I am therefore closing this as fixed, but feel free to reopen if it should resurface.

Best, Daniel

daogrady avatar Mar 04 '25 09:03 daogrady