cancel
Showing results for 
Search instead for 
Did you mean: 

SAP CAP Typescript - Error - Could not find a declaration file for module '@sap/cds'

sandeepmalhotra
Participant
2,070

Hello Everyone 

I am using typescript with CAP

After upgrading to new version, I start getting following error

Could not find a declaration file for module '@sap/cds'. '/project/node_modules/@sap/cds/lib/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/sap__cds` if it exists or add a new declaration (.d.ts) file containing `declare module '@sap/cds';`ts(7016)

for statement

import cds from "@sap/cds";
 
Version details
 
@cap-js/asyncapi: 1.0.1
@cap-js/cds-typer: 0.24.0
@cap-js/openapi: 1.0.4
@cap-js/sqlite: 1.7.1
@Sisn/cds: 8.0.3
@Sisn/cds-compiler: 5.0.6
@Sisn/cds-dk: 8.0.2
@Sisn/cds-dk (global): 8.0.2
@Sisn/cds-fiori: 1.2.7
@Sisn/cds-foss: 5.0.1
@Sisn/cds-hana: 2.0.0
@Sisn/cds-mtxs: 2.0.2
@Sisn/cds-odata-v2-adapter-proxy: 1.9.21
@Sisn/eslint-plugin-cds: 3.0.4
Node.js: v20.13.1
 
Also getting error  Cannot find name **** (2304)  for SELECt,DELETE,UPDATE statements
 
Kindly let me know how to fix it 

 

View Entire Topic
Trulov
Participant

Hi @sandeepmalhotra ,

the types have moved to the cap-js/cds-types package. So just install it via `npm i -D @cap-js/cds-types` and there you have all your types in one .d.ts file.

BR Tom

Matthias_Kolley
Explorer
0 Kudos
With Version 0.8.0 this error occurs again. So i reverted back to 0.6.5
thomolka1
Newcomer
0 Kudos
I've encountered the problem also for cds-8.6.0. I spent some time to analyze it and what helped me was to add the following script to package.json file: "postinstall": "test -L node_modules/@types/sap__cds || ln -s ../@cap-js/cds-types node_modules/@types/sap__cds" (works on linux/macos systems)