Giter Club home page Giter Club logo

Comments (6)

riyadhalnur avatar riyadhalnur commented on July 1, 2024

Definitely something worth introducing. Thanks for the suggestion.

from mongoose-softdelete.

riyadhalnur avatar riyadhalnur commented on July 1, 2024

I released a new version of this plugin v1.1.0 that adds types. Please try it out and let me know if it works for your use case. Cheers!

from mongoose-softdelete.

tomcanac avatar tomcanac commented on July 1, 2024

Hi,

I do have some problems here, I put them here, let me know if you think this is the type definition or my implementation.

1- I used import mongooseSoftDelete from "mongoose-softdelete"; instead of require, because with Require, TS seems to cast the plugin to a type of any (thus, deactivating TS type). So here is my first not-by-the-doc line.

2- I tried to import the plugin in my root mongoose file and apply this to the mongoose global object, like this:

  mongoose.connect(uri, connectionParams);
  mongoose.plugin(mongooseSoftDelete);

and It gives me this warning:

Argument of type 'typeof import("/home/user/work/project-api/node_modules/mongoose-softdelete/index")' is not assignable to parameter of type '(schema: Schema<any>) => void'.
  Type 'typeof import("/home/user/work/projet-api/node_modules/mongoose-softdelete/index")' provides no match for the signature '(schema: Schema<any>): void'.ts(2345)

Note that even when I add the plugin directly to my schemas, It gives me the same warning.

Do you experience the same errors or does it looks like it is on my side?
Thanks for the help!

from mongoose-softdelete.

madeindjs avatar madeindjs commented on July 1, 2024

I resolved typing issue with this

import softDelete from 'mongoose-softdelete';
// ...
userSchema.plugin(softDelete as () => Schema<any>);

Also maybe it is simplier to make a PR on https://github.com/DefinitelyTyped/DefinitelyTyped ?

from mongoose-softdelete.

riyadhalnur avatar riyadhalnur commented on July 1, 2024

@madeindjs PRs are always welcomed 😃

from mongoose-softdelete.

madeindjs avatar madeindjs commented on July 1, 2024

@riyadhalnur , I made a simple PR 😉

from mongoose-softdelete.

Related Issues (10)

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.