cancel
Showing results for 
Search instead for 
Did you mean: 

Code completion with CDS Typer does not work

MioYasutake
Active Contributor
0 Kudos

Hi community,

I have created a TypeScript-based project that utilizes CDS Typer to generate types.

My problem is that VS code does not provide auto-completion based on the types. In the screen shot below, I expected that elements of the Books entity would be suggested, but it only suggested generic elements.

Am I missing any configurations in either the project or VS code?

Any insights or suggestions to resolve this issue would be greatly appreciated.

Best regards,

Mio

View Entire Topic
daniel_ogrady
Explorer
0 Kudos

Hi Mio,

I checked your code and noticed two problems that prevented code completion:

1. your `rootDir` in your tsconfig.json is set to `"./srv"`, which excludes the directory the types are generated into. One possible fix is to set it to `"."` instead or to make use of the `rootDirs` setting.

2. once you have done that, you should use a dynamic import to include the types where you are currently using `require(...)`. Note that this change will make your ìnit()` method `async`.

With these two changes you should receive proper code completion.

If you have more questions regarding cds-typer or find a bug, please opene a bug report or question ticket in the project's open source repository.

Best,
Daniel

MioYasutake
Active Contributor
0 Kudos

Hi daniel.ogrady,

Thank you very much for your advice. It worked!