cap-js / cds-typer

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

[BUG] CDSDate / CdsTimestamp not generated / found #228

Open tsteckenborn opened 2 months ago

tsteckenborn commented 2 months ago

Is there an existing issue for this?

Nature of Your Project

TypeScript

Current Behavior

I guess another quite minimal sample for this issue is:

service Test {
    entity test.TestEntity : managed {}
    entity TestEntity as projection on test.TestEntity;
}

Within the generated TypeScript files you can find:

export function _temporalAspect<TBase extends new (...args: any[]) => object>(Base: TBase) {
  return class temporal extends Base {
        validFrom?: __.CdsTimestamp | null;
        validTo?: __.CdsTimestamp | null;
      static readonly actions: Record<never, never>
  };
}

With the CdsTimestamp reporting (same e.g. with CdsDate):

Namespace '"/Users/.../.../.../@cds-models/_/index"' has no exported member 'CdsTimestamp'.ts(2694)

Expected Behavior

These types to be generated

Steps To Reproduce

See above

Environment

- **OS**: MacOS
- **Node**: 20.12.2
- **npm**: /
- **cds-typer**: branch fix/parameter-type-references
- **cds**: 7.8.1

Repository Containing a Minimal Reproducible Example

No response

Anything else?

No response

daogrady commented 1 month ago

Hi Tobias,

thanks for the report! I'm afraid I can not reproduce the issue from your minimal sample. I am seeing a _/index.ts with the contents:

// ...
/**
 * Dates and timestamps are strings during runtime, so cds-typer represents them as such.
 */
export type CdsDate = `${number}${number}${number}${number}-${number}${number}-${number}${number}`;
/**
 * @see {@link CdsDate}
 */
export type CdsDateTime = string;
/**
 * @see {@link CdsDate}
 */
export type CdsTime = `${number}${number}:${number}${number}:${number}${number}`;
/**
 * @see {@link CdsDate}
 */
export type CdsTimestamp = string;

would you mind checking again with the latest version of cds-typer?