Skip to content

Missing Imports for references #48

@CedricSchreiner

Description

@CedricSchreiner

Version used: 3.0.0
CDS Version: 6.3.2

As an example we have two different CDS files which have a reference to each other. If you now execute cds2types, the corresponding files are generated, however, they are currently incorrect because each is missing in import.

Here a simple Example:

BusinessTransactionPayload:

using {
  managed,
  cuid,
} from '@sap/cds/common';
using {entities.message.TransferDocument} from './transfer-document';

namespace entities.shadow;

entity BusinessTransactionPayload : managed {
  key uuid                        : UUID;
      transferDocumentUUID        : UUID;
      transferDocument            : Association to one TransferDocument
                                      on transferDocument.uuid = $self.transferDocumentUUID;
}

TransferDcoument

using {
  managed,
  cuid,
} from '@sap/cds/common';
using {entities.shadow.BusinessTransactionPayload} from './business-transaction';


namespace entities.message;

entity TransferDocument : managed {
  key uuid                                      : UUID;
      toBusinessTransaction                     : Composition of many BusinessTransactionPayload
                                                    on toBusinessTransaction.transferDocumentUUID = $self.uuid;
}

Compiles to

export interface IBusinessTransactionPayload {
  uuid: string;
  transferDocumentUUID: string;
  transferDocument?: entities.message.ITransferDocument;
}
export interface ITransferDocument {
  uuid: string;
  toBusinessTransaction: entities.shadow.IBusinessTransactionPayload[];
}

The problem here is that the generated Typescript file can not find the reference to entities.message.ITransferDocument or entities.shadow.IBusinessTransactionPayload because these are both in separate generated files. When a import is manually added its working. Is this behavior intended?

Kind Regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions