cap-js / cds-types

Type definitions for CDS
Apache License 2.0
10 stars 10 forks source link

[BUG] Cannot find name 'SELECT' and 'INSERT' #294

Open LeCongNam opened 1 week ago

LeCongNam commented 1 week ago

Is there an existing issue for this?

Current Behavior

Expected Behavior

no error found npm run npm run build typescript

References

https://community.sap.com/t5/technology-q-a/sap-cap-typescript-error-could-not-find-a-declaration-file-for-module-sap/qaq-p/13764999

Versions

PRIVATE MY REPO https://github.com/my-repo
@cap-js/asyncapi 1.0.2
@cap-js/openapi 1.0.5
@sap/cds 8.3.1
@sap/cds-compiler 5.3.2
@sap/cds-dk (global) 8.1.1
@sap/cds-fiori 1.2.7
@sap/cds-foss 5.0.1
@sap/cds-hana 2.0.0
@sap/cds-mtxs 2.0.5
@sap/eslint-plugin-cds 3.0.4
Node.js v20.16.0

Anything else? Logs?

i'm using feature package of gitlab. when i run npm i i want all package install for all repository dependency. i'm used "@cap-js/cds-types": "^0.6.5" when upgrade cds version 6 to version 8 with npm i -D @cap-js/cds-types Current build CICD error when build. I'm used trig install npm i @cap-js/cds-types work well but not true because this package for dev mode not for production mode. Please help me. Thanks you so much

daogrady commented 1 week ago

Hi @LeCongNam ,

thanks for reporting this issue. I am not quite clear on what you mean by

because this package for dev mode not for production mode

We generally recommend to deploy only transpiled JavaScript in a productive scenario, so types should not play a role once you deploy. If you choose to run TypeScript in a productive scenario, then @cap-js/cds-types also has to be a regular dependency.

Best, Daniel

Markus-Schroeder-de commented 1 week ago

this problem occurs if the npm link ist missing, have a look on other issues... you could solve it with "npm rebuild"

You need to find this entry: npm list|grep ├── @types/sapcds@npm:@cap-js/cds-types@0.6.5 extraneous -> ./node_modules/@cap-js/cds-types

LeCongNam commented 1 week ago

Hi @LeCongNam ,

thanks for reporting this issue. I am not quite clear on what you mean by

because this package for dev mode not for production mode

We generally recommend to deploy only transpiled JavaScript in a productive scenario, so types should not play a role once you deploy. If you choose to run TypeScript in a productive scenario, then @cap-js/cds-types also has to be a regular dependency.

Best, Daniel

Thanks @daogrady support me. But I confure because @cap-js/cds-types is TYPE in typescript will install for dev-dependency and support suggest type for coding local. But you suggest for build production. I think it not helpful for production mode with run time because cds v6 do not include type. I think if this package required for build prodction you have create Pull Request merge this package for Sap SDK. Thanks you

LeCongNam commented 1 week ago

this problem occurs if the npm link ist missing, have a look on other issues... you could solve it with "npm rebuild"

You need to find this entry: npm list|grep ├── @types/sapcds@npm:@cap-js/cds-types@0.6.5 extraneous -> ./node_modules/@cap-js/cds-types

Thanks you suggest you. But i want npm auto install. I install like @daogrady and fixed it. But I'm don't happy install types for dependency so i ask and received answer like me :) funny

daogrady commented 1 week ago

Hi @LeCongNam ,

I am still a bit unclear on your scenario.

install for dev-dependency and support suggest type for coding local. But you suggest for build production.

Yes, that is correct. We recommend you only use TypeScript (and in consequence: @cap-js/cds-types) in your local development scenario. Yet, you said:

Current build CICD error when build

This implies, that you are either

(a) attempting to run TypeScript productively, or (b) your CICD does not install the devDependencies.

If your CICD includes a build step from TypeScript to JavaScript, then you do need the @cap-js/cds-types package present when the build happens. So you can either have your build step use the devDependencies, or promote @cap-js/cds-types to a full dependency.

Best, Daniel