cap-js / cds-typer

CDS type generator for JavaScript
Apache License 2.0
29 stars 10 forks source link

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

Open mcastrup opened 10 months ago

mcastrup commented 10 months ago

Is there an existing issue for this?

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

hakimio commented 10 months ago

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.

mcastrup commented 10 months ago

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

daogrady commented 10 months ago

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

mcastrup commented 9 months ago

Hi Daniel,

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

Thanks and best regards, Michael

daogrady commented 9 months ago

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

github-actions[bot] commented 8 months ago

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.