cap-js / cds-typer

CDS type generator for JavaScript
Apache License 2.0
27 stars 8 forks source link

[BUG] actions correctly generated in TS-Type but not in JS-File #247

Closed Kyrodan closed 4 months ago

Kyrodan commented 4 months ago

Is there an existing issue for this?

Nature of Your Project

JavaScript, TypeScript

Current Behavior

I created a Entity with a simple (void) action:

entity IH_Items          as projection on ih.IH_Items
        actions {
            action myAction();
        }

The generate TS-Type-Stub looks (correctrly) like this:

export function _IH_ItemAspect<TBase extends new (...args: any[]) => object>(Base: TBase) {
  return class IH_Item extends Base {
      [...]
      static readonly actions: {
        myAction: { (): any, __parameters: Record<never, never>, __returns: any, kind: 'action'}
      }
  };
}

But in the generated JS-Type this action is missing:

function _IH_ItemAspect(Base) {
    return class IH_Item extends Base {
        [...]
        static actions;
    };
}

Expected Behavior

Action is also generated for JS-Type-File.

Steps To Reproduce

  1. create an entity with a (void) bound action
  2. run cds-typer

Environment

- **OS**: Windows + Linux
- **Node**: v20.13.1
- **npm**: 10.8.0
- **cds-typer**: 0.21.0
- **cds**: 7.9.1

Repository Containing a Minimal Reproducible Example

No response

Anything else?

No response

Kyrodan commented 4 months ago

No Bug. Problem solution in #252