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

Typescript Node The operand of a 'delete' operator must be optional. Ts(2790)error #85

Closed
dariocoroneldev opened this issue Dec 19, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@dariocoroneldev
Copy link

System (please complete the following information):

  • OS: macos
  • node v12.19.0
  • typescript 4.1.3

Describe the bug
when i making a simple post on my node aplication i recibe the request body i making a normal post for a user so when i take all the user data and i execute a save before i send my json i have to delete the password for use in the get so is when the bug appears in a message: "{
"resource": "/Users/dariocoronel/Desktop/practices/Gostack/gobarber/backend/src/routes/users.routes.ts",
"owner": "typescript",
"code": "2790",
"severity": 8,
"message": "The operand of a 'delete' operator must be optional.",
"source": "ts",
"startLineNumber": 24,
"startColumn": 20,
"endLineNumber": 24,
"endColumn": 33
}"

To Reproduce
Steps to reproduce the behavior:

  1. create a simple normal post in a node with express
  2. get all the request body data then save it to the basedata
  3. when you try to send a json with this that but you want delete user password before send all the data to a get for a list
  4. See error "The operand of a 'delete' operator must be optional."ts(2790) [24.20]

Expected behavior
i want to solve this problem

Screenshots or error log
here we can see clarily how the bug appears
Screen Shot 2020-12-18 at 23 22 59

Additional context
someone can helpme please

@dariocoroneldev dariocoroneldev added the bug Something isn't working label Dec 19, 2020
@halvardssm
Copy link
Owner

Hi, this is a typescript specific feature which is better asked on stack overflow than here, but as I was curious, I searched up the error and here is the solution. Hope it helps 😊 https://stackoverflow.com/questions/63702057/what-is-the-logic-behind-error-the-operand-of-a-delete-operator-must-be-opti

@dariocoroneldev
Copy link
Author

Thanks, i'm a new programer sorry for making my question on the wrong place, i gonna use more stackoverflow i didn't know anything jet about this incredible world! thanks!

@PrakashDahal
Copy link

I think this is perfectly fine @dariocoroneldev. It is all about learning and growing.
I found my solution because of you. Thank you

@ekawatani
Copy link

Hi, this is a typescript specific feature which is better asked on stack overflow than here, but as I was curious, I searched up the error and here is the solution. Hope it helps 😊 https://stackoverflow.com/questions/63702057/what-is-the-logic-behind-error-the-operand-of-a-delete-operator-must-be-opti

FYI, the link only mentions how to workaround the problem, but it does not explain why the error exists in the first place. If you are casting something with as, of course the problem goes away, but that does not fix the underlying problem. Well, whether you care about the error is a different issue though and you may be perfectly fine with just bypassing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants