Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SUGGESTION] Types for cds.builtin.types #359

Open
1 task done
Akatuoro opened this issue Dec 3, 2024 · 4 comments
Open
1 task done

[SUGGESTION] Types for cds.builtin.types #359

Akatuoro opened this issue Dec 3, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@Akatuoro
Copy link
Contributor

Akatuoro commented Dec 3, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

const { Date } = cds.builtin.types
// -> const Date: object
const { today } = cds.builtin.types.Date
// -> Property 'today' does not exist on type '{}'.ts(2339)

Expected Behavior

Proper types for cds.builtin.types

References

https://github.com/SAP-samples/cap-sflight/blob/5154e2eece13485cfaa9f6ea041b3e6f81276743/srv/travel-service.ts#L9

Versions

@capire/sflight https://github.com/SAP-samples/cap-sflight
@cap-js/cds-typer 0.29.0
@cap-js/cds-types 0.8.0
@cap-js/db-service 1.16.0
@cap-js/hana 1.5.0
@cap-js/sqlite 1.7.7
@sap/cds 8.5.0
@sap/cds-compiler 5.5.0
@sap/cds-fiori 1.2.8
@sap/cds-foss 5.0.1
@sap/cds-mtxs 2.3.1
CAP Java SDK 3.5.0
Java 21.0.5, home: /Library/Java/JavaVirtualMachines/sapmachine-21.
Maven 3.6.3
Node.js v22.7.0
OS Mac OS X, 14.6.1, arch: x86_64
Spring Boot 3.4.0
cds4j 3.5.0

Anything else? Logs?

No response

@Akatuoro Akatuoro added the bug Something isn't working label Dec 3, 2024
@daogrady
Copy link
Contributor

daogrady commented Dec 3, 2024

Where does today come from? 🤔 (now?)

@Akatuoro
Copy link
Contributor Author

Akatuoro commented Dec 4, 2024

Where does today come from? 🤔 (now?)

It returns '2024-12-04', so a string. If you debug into the function, it's part of cds and runs (new Date).toISOString().slice(0,10). It can be set to a Date field.

It's not documented yet on capire....

@daogrady
Copy link
Contributor

daogrady commented Dec 4, 2024

We should consider things that are not documented on CAPire non-public -- unless they have been forgotten, obviously. 🙂
@mariayord could you please let us know if cds.Date::today is supposed to be public API?

@mariayord
Copy link

@mariayord could you please let us know if cds.Date::today is supposed to be public API?

@danjoa Could you please answer the question? Until now we were not aware of this option. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants