Git Product home page Git Product logo

Comments (9)

myty avatar myty commented on September 27, 2024 1

I imagine there could be more instances where we could use this but figured it's a good start with the ones that have been identified so far.

from andculturecode.javascript.core.

dtnhinh avatar dtnhinh commented on September 27, 2024

Can I be assigned to this issue? Thanks

from andculturecode.javascript.core.

brandongregoryscott avatar brandongregoryscott commented on September 27, 2024

Oh, sweet! I think I understand - so for the CollectionUtils methods, this will alleviate the need to use the forced non-null operator (!) on results that have been passed through it?

from andculturecode.javascript.core.

myty avatar myty commented on September 27, 2024

Oh, sweet! I think I understand - so for the CollectionUtils methods, this will alleviate the need to use the forced non-null operator (!) on results that have been passed through it?

Exactly! 👏

from andculturecode.javascript.core.

dtnhinh avatar dtnhinh commented on September 27, 2024

Type guard can be done easily for single parameter (i.e. isEmpty(value?: string)) but not for rest parameter (hasValue(...collections: Array<T>)
image
I am looking to see if there are some user defined type guard for this case

from andculturecode.javascript.core.

brandongregoryscott avatar brandongregoryscott commented on September 27, 2024

@dtnhinh Let me know if you find anything that can help narrow down type guards for a rest parameter. If we can't, I'm not opposed to updating the signature of that function to take a single 'collection' - I believe the rest parameter was added to solve some tedious resultObject/API response checking in a complex component for an internal project, but I haven't seen it widely used since. It would be a breaking change, do we feel like the compiler type guard outweighs the rest parameter?

from andculturecode.javascript.core.

dtnhinh avatar dtnhinh commented on September 27, 2024

I have done some researches but I don't think there is a type guard workaround for rest parameter. I have never seen a case where we parse multiple arguments rather than one single array so I can't say if rest parameter would ever be useful in the future use. Array type guard is very common so let me know if you think we should switch to single collection

from andculturecode.javascript.core.

brandongregoryscott avatar brandongregoryscott commented on September 27, 2024

Let's just switch to a single collection @dtnhinh. If we really need one with a rest parameter/multiple collections at once, we can open up a new issue and add in separate function(s) to accomplish that. I think the type guard is a huge advantage for developer ease of use 👍

from andculturecode.javascript.core.

brandongregoryscott avatar brandongregoryscott commented on September 27, 2024

Published with v0.4.0

from andculturecode.javascript.core.

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.