on 12-14-2023 9:18 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
74 | |
9 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.