Giter Site home page Giter Site logo

Comments (24)

tauqeernasir avatar tauqeernasir commented on May 3, 2024 8

Actually, this body-parser repo is pure javascript. Type for this project is coming from @types/body-parser, which has been updated. Express ^v4.16.0 has built-in express.urlencoded and express.json middlewares now. Please consider using this new one to avoid these warnings.

from body-parser.

SekMicra avatar SekMicra commented on May 3, 2024 6

is either an issue with VS Code or the typescrip

I think this is not a problem from the vs-code side. The problem occurs due to added deprecated decorator in the typescript file.
If the method is not deprecated then why there is a deprecated decorator in the typescript file.
Because of that decorator, The intelligence of vs-code shows the message that bodyparser is deprecated.

As per my answer, if there is not needed to that decorator, then kindly remove it from the upcoming version and the problem will solve.

from body-parser.

dougwilson avatar dougwilson commented on May 3, 2024 3

Thanks @akshaymemail . It sounds like it is either an issue with VS Code or the typescripts, neither of which we have created or manage. My guess is it is from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/body-parser/index.d.ts#L19 but I'm not a Typescript expert. You may want to file an issue with that project maybe, not sure. Unfortunately there isn't anything we can do here, unless you have some specific suggestion.

from body-parser.

akshaymemail avatar akshaymemail commented on May 3, 2024 2

Thanks @dougwilson , I removed deprecated notation from file index.d.ts line no 19 and now vs code is not giving any warning 😁

Then :
tt

Now :
t2

from body-parser.

akshaymemail avatar akshaymemail commented on May 3, 2024 1

code :
Screenshot 2021-03-08 083427

Warning generated by VS Code :
1
2

from body-parser.

dougwilson avatar dougwilson commented on May 3, 2024 1

Hi @SekMicra this project did not make that file, which is why the issue is closed here. You can see by looking at the repo here there is no such file as well.

from body-parser.

dougwilson avatar dougwilson commented on May 3, 2024 1

Hi @dedo1911 no need to repeat what I already wrote here back to me :) just telling me what I already said doesn't really solve anything

from body-parser.

dougwilson avatar dougwilson commented on May 3, 2024

Hm, I'm not sure why you would get that. What is generating the message and where does it come from?

from body-parser.

SekMicra avatar SekMicra commented on May 3, 2024

Thanks @akshaymemail . For making this issue. I am also facing this problem. I tried many solution but does not work.

from body-parser.

SekMicra avatar SekMicra commented on May 3, 2024

emoved deprecated notation from file index.d.ts line no 19 and now vs c

But this is not any proper solution to fix in the project. For this we need to make changes in node_modules. and that's not a right way or proper solution.

from body-parser.

dedo1911 avatar dedo1911 commented on May 3, 2024

@dougwilson It's coming from this repo https://github.com/DefinitelyTyped/DefinitelyTyped specifically on this file/line: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/body-parser/index.d.ts#L19
Which serves this package: https://www.npmjs.com/package/@types/body-parser

from body-parser.

thernstig avatar thernstig commented on May 3, 2024

@SekMicra as @dougwilson already pointed out, VS Code automatically download type definitions for JavaScript projects from this Github repo:
https://github.com/DefinitelyTyped/DefinitelyTyped. So you need to file an issue there.

More specifically as already pointed out, this line in that repo is incorrect: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/body-parser/index.d.ts#L19

Could you write an issue there?

from body-parser.

eyoeldefare avatar eyoeldefare commented on May 3, 2024

@dedo1911

Hey, the issue is someone has deprecated the function in index.js file in version 1.19.0.
Look at the file, shouldn't be that hard.


/**

 * Create a middleware to parse json and urlencoded bodies.
 *
 * @param {object} [options]
 * @return {function}
 * @deprecated  //---------------------------------DEPRECATED----------------------------------
 * @public
 */

  function bodyParser (options) 

from body-parser.

dougwilson avatar dougwilson commented on May 3, 2024

Yes, that function in index.js is, indeed, deprecated. Please do not use app.use(bodyParser()) . Instead use the different functions exported for each type as documeted in the readme.

from body-parser.

eyoeldefare avatar eyoeldefare commented on May 3, 2024

Yes, that function in index.js is, indeed, deprecated. Please do not use app.use(bodyParser()) . Instead use the different functions exported for each type as documeted in the readme.

That is not how I am using it, I am using it as the readme file instructs which is

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));

The problem is, since the function is deprecated, everything derived from it will also be deprecated.

from body-parser.

dougwilson avatar dougwilson commented on May 3, 2024

Hi @eyoeldefare how is that? How do you propose the function be deprecated then? Also seems weird that we have had it like that for years now, but suddenly it was reported multiple times. Something changed recently, but it wasn't the deprecation mark in this module's source code... Please explain how you are seeing a deprecation message for your above usage and can you show exactly how it is derived? Does editing the index.js in your node_modules folder fix the issue?

from body-parser.

eyoeldefare avatar eyoeldefare commented on May 3, 2024

Hi @eyoeldefare how is that? How do you propose the function be deprecated then? Also seems weird that we have had it like that for years now, but suddenly it was reported multiple times. Something changed recently, but it wasn't the deprecation mark in this module's source code... Please explain how you are seeing a deprecation message for your above usage and can you show exactly how it is derived? Does editing the index.js in your node_modules folder fix the issue?

I will try that and come back real quick. Might be vcode issue too because I updated that just yesterday.

from body-parser.

eyoeldefare avatar eyoeldefare commented on May 3, 2024

I solved it by just using express.json() and express.urlencoded() instead since I am using Express >= 4.16.0, but the problem seem to me that either vscode is messing up or something in the below code snipet.

var deprecate = require('depd')('body-parser')

exports = module.exports = deprecate.function(bodyParser,
  'bodyParser: use individual json/urlencoded middlewares')

Note it wraps the bodyParser function in deprecate.function(). Since it does that, its noted as deprecated perhaps. Somewhere there must be the issue. Anyways thanks.

from body-parser.

dougwilson avatar dougwilson commented on May 3, 2024

Hi @eyoeldefare so are you saying that if you edited that line, the deprecation you are seeing goes away? The original error you posted ended in in index.d.ts file. You are positive the issue is in index.js file? I wonder why the message would say a different file name if that is the case.

from body-parser.

eyoeldefare avatar eyoeldefare commented on May 3, 2024

Hey, well yeah I did removed @Deprecation from the file and it only fixed only the error showing on the bodyParser on deprecate.function(bodyParser...) function. But it didn't fix it in my application. Which is why I said the issue could have been from feeding bodyParser into a deprecate function like deprecate.function().

Also, yes, I said index.d.ts file initially because js file is compiled to ts in vscode. So that is also a possible place this bug is happening.

from body-parser.

eyoeldefare avatar eyoeldefare commented on May 3, 2024

Okay before I leave this subject, I just want to say that this issue is most definitely from vscode compiling the js files to ts files when it catches the files and store them in our computer and most likely this happened after the new update to vscode made to typescript 4.2.3. As to why? I don't know. Now I understand that removing the @Deprecation from index.js most likely didn't affect my application because my change to the node_module file is not take effect since the files are already catched and stored on my computer. So, removing @Deprecation could actually work. I just don't know how to force vscode to make it compile my new change to the file and figuring that out can take some time. But I am sure, this info will help you guys. Peace

from body-parser.

dougwilson avatar dougwilson commented on May 3, 2024

Thanks for the information @eyoeldefare . I'm not familiar with that environment or Typescript, so not sure how I can help. If someone can provide some definitive "changing x will fix y" we can certainly make the change. The change can be tested out without publishing a new version of this module, testing, publishing, testing again, I'm sure of it, as that would be pretty crazy 😂 . Even some definitive documentation around it would be very helpful that explains what makes the message you are seeing.

from body-parser.

fdo36 avatar fdo36 commented on May 3, 2024

I am back again to give you guys more info for the good of humanity.
So first of all, let me say that I fixed the problem completely and it has nothing to do with @Deprecation or body-parser.

So it turns out, VSCode compiles the javascript files used inside of body-parser into typescript for lint reasons like showing us errors, warning, and better programming experience overall. So, when it does that, the catched files are stored inside AppData in our computer for ease of accessing the catched files. So once I figured that out, I simply deleted all of the catched files inside my computer, C:\Users\eyoel\AppData\Local\Microsoft\TypeScript\4.2\node_modules and I also removed node_module from my application, and npm update, now when npm updates the new files, VSCode is forced to compile that and catch the new files. That completely fixed it for me and I didn't even have to down grade the typescript version. I am still using 4.2.3 (latest). Cheers.

that doesn't work for me. i'm using Ubuntu 20.04.2 LTS with node v14.16.0 and npm v6.14.11 and the cached files are inside of ~/.cache/typescript/4.2/node_modules.

I followed your instructions and after npm update always appears the index.d.ts with the bodyParser deprecated. I have to delete the anotation as someone commented and it seems to work fine

from body-parser.

eyoeldefare avatar eyoeldefare commented on May 3, 2024

Actually, this body-parser repo is pure javascript. Type for this project is coming from @types/body-parser, which has been updated. Express ^v4.16.0 has built-in express.urlencoded and express.json middlewares now. Please consider using this new one to avoid these warnings.

Yeah I am using that too despite solving the issue on my end. Just don't want to deal with the unknown.

from body-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.