docs icon indicating copy to clipboard operation
docs copied to clipboard

add impl() noop wrapper to simple sample

Open qmacro opened this issue 9 months ago • 2 comments

The sample given had a const cds = require('@sap/cds') but didn't use the cds after that. Moreover, the constant was then highlighted in VS Code as unused, with a rather urgent red squiggly line, which no-one wants :-)

I suggest that rather than omit this line, perhaps it's better to leave it in and use it to provide the noop wrapper that enables Intellisense.

qmacro avatar May 02 '24 14:05 qmacro

Thanks for the hint @qmacro. Looks like a nice way out of the 'unused var' issue. The thing that bothers me is that our docs refer to cds.service.impl as 'old-style'. So I wonder if should rather use the class pattern (cds.ApplicationService) although that's a bit harder to grasp for beginners. @qmacro @sjvans opinions?

chgeo avatar May 03 '24 07:05 chgeo

i lean towards removing cds rather than showing the old style or the more complex class approach. the import is not really needed as we add global.cds anyways. and if your liniting rules don't consider that, then you can add it once you need it in your impl.

sjvans avatar May 03 '24 08:05 sjvans