Devtoberfest
Find out what's happening, and when, in the Devtoberfest schedule – don't miss out!
cancel
Showing results forΒ 
Search instead forΒ 
Did you mean:Β 

🟒 How to build a CAP plugin with Node.js

Devtoberfest

Learn how to develop your first plugin in CAP Node.js and connect it with a CAP application. Enrich the plugin with functionality, learning the different techniques on how a plugin can interact with the base app.

Speakers: Daniel Schlachter, Ram Prasad and Robin De Silva

Validation tutorial for todays sessions will be available by the end of the day here: https://developers.sap.com/tutorials/devtoberfest2024-week3-cap-session-validation.html



Event has ended
You can no longer attend this event.

Starts:
Ends:
3 Comments
FedericoBelotti
Explorer

Hello everyone,
I was wondering if it is possible to develop design time plugins (e.g. cds add <plugin>) using TypeScript. I couldn't find a way to use the @Priya0/cds-dk package since it doesn't come with type definitions. Am I missing something obvious or it isn't effectively possible (possibly without allowing Js code and any types in the tsconfig πŸ™‚ )?

Thanks

FedericoBelotti
Explorer

Hello @KevinR,
I may have been explained myself poorly. What I meant wasn't that I couldn't use TypeScript at all within a CAP application, but rather that I couldn't use the '@sap/cds-dk' package imports inside a .ts file to create a CDS plugin with TypeScript rather than the '@sap/cds' package. The resources you suggested are fine and I can have them working in a CAP application.
I have set up an empty, dummy node application that uses TypeScript and inside the cds-plugin.ts file I tried to import something from '@sap/cds-dk' trying to replicate what is explained here but all I get is:
"Could not find a declaration file for module '@sap/cds-dk'. '<PATH>/cap-plugin-ts/node_modules/@sap/cds-dk/lib/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/sap__cds-dk` if it exists or add a new declaration (.d.ts) file containing `declare module '@sap/cds-dk';`"

@types/sap__cds-dk declarations do not exist as they do for '@sap/cds', so it doesn't seem to be possible to use the sdk in a .ts file.

Thanks for any help,
Federico