Comments (9)
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.
Can I be assigned to this issue? Thanks
from andculturecode.javascript.core.
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.
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.
Type guard can be done easily for single parameter (i.e. isEmpty(value?: string)
) but not for rest parameter (hasValue(...collections: Array<T>
)
I am looking to see if there are some user defined type guard for this case
from andculturecode.javascript.core.
@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.
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.
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.
Published with v0.4.0
from andculturecode.javascript.core.
Related Issues (20)
- npm run watch no longer runs tsc --watch
- StringUtils.isEmpty type guard types value as 'never' when false HOT 7
- Add type guard for RecordUtils.isRecord
- Add Lodash chunk and flatten to collection utils HOT 1
- Add 'Cache-Control' HttpHeader enum
- Add functionality to pull culture from route HOT 1
- Fix skipped LocalizationUtils.detectCultureCode test
- Reevaluate production vs. peer/dev dependencies HOT 4
- Allow consumer to control 'debug' option for LocalizationUtils/i18next
- Move + export LocalizationInitOptions interface from LocalizationUtils
- Implement network information utilities
- Update README with section on internationalization
- Lighten peer dependency version further
- ReferenceError exception when window is not defined HOT 1
- Add null to the collection type and type guard
- AuditableDefaultValues / Factory for requiring properties to be set
- Upgrade node requirement to v16 LTS HOT 1
- Add 'Content-Length' HttpHeader enum
- Slow workflow/npm install for cypress HOT 2
- Add AriaRole Enum to /src/enumerations
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from andculturecode.javascript.core.