Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
LeCongNam opened this issue Oct 24, 2024 · 8 comments
Closed
1 task done

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

LeCongNam opened this issue Oct 24, 2024 · 8 comments
Labels
help wanted Extra attention is needed

Comments

@LeCongNam
Copy link

LeCongNam commented Oct 24, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

  • error TS2304: Cannot find name 'DELETE'
  • error TS2304: Cannot find name 'INSERT'.

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

@LeCongNam LeCongNam added the bug Something isn't working label Oct 24, 2024
@daogrady
Copy link
Contributor

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
Copy link

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/sap__cds@npm:@cap-js/[email protected] extraneous -> ./node_modules/@cap-js/cds-types

@LeCongNam
Copy link
Author

LeCongNam commented Oct 24, 2024

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
Copy link
Author

LeCongNam commented Oct 24, 2024

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/sap__cds@npm:@cap-js/[email protected] 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
Copy link
Contributor

daogrady commented Oct 24, 2024

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

@daogrady daogrady added help wanted Extra attention is needed and removed bug Something isn't working labels Oct 24, 2024
@ZhongpinWang
Copy link

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/sap__cds@npm:@cap-js/[email protected] extraneous -> ./node_modules/@cap-js/cds-types

Hi @Markus-Schroeder-de , we had the same issue when trying to import something from @sap/cds in typescript.

Could not find a declaration file for module '@sap/cds'. '****/ai-sdk-js/node_modules/.pnpm/@[email protected][email protected]/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)

Check the Known Issue section in SAP/ai-sdk-js#273. As this creates complication for users, could this problem be solved? I can imagine almost everyone who uses CAP with typescript will face this issue.

@daogrady
Copy link
Contributor

Hi @ZhongpinWang ,

I believe you wanted to add this response to #251

Best,
Daniel

@daogrady
Copy link
Contributor

Considering this solved due to inactivity. Feel free to open another issue if the problem persist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants