cap-js / cds-typer

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

Fix event import #383

Closed GoldSucc closed 2 weeks ago

GoldSucc commented 2 weeks ago

Fixes https://github.com/cap-js/cds-typer/issues/382 (event import error).

Janhouse commented 2 weeks ago

Tested, seems to fix the issue.

chgeo commented 2 weeks ago

Can you provide more context on the issue?

Janhouse commented 2 weeks ago

@chgeo open the mentioned issue #382

GoldSucc commented 2 weeks ago

@chgeo when cds definition (.cds file) contains only events/operations it generates type without import which is incorrect ts file. tsc produces type errors indeed because no import is present. to get this error, event/operation should use type like Timestamp (something that comes from . like __.CdsTimestamp).

chgeo commented 2 weeks ago

@chgeo when cds definition (.cds file) contains only events/operations it generates type without import which is incorrect ts file. tsc produces type errors indeed because no import is present. to get this error, event/operation should use type like Timestamp (something that comes from . like __.CdsTimestamp).

I see. So I will add a test for that before merging. Alternatively, you can give it a try. See our testing guide for this. Lately, we added compilation tests which are easier to write than the AST ones.

GoldSucc commented 2 weeks ago

@chgeo I have some experience with code generation and syntax trees so I decided to implement tests in AST. Committed changes with tests.