-
Notifications
You must be signed in to change notification settings - Fork 10
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
fix: improve typing of flatten to infer return iterator type #22
base: master
Are you sure you want to change the base?
fix: improve typing of flatten to infer return iterator type #22
Conversation
Also add a test for flatten, based on flatten.test.ts
Codecov Report
@@ Coverage Diff @@
## master #22 +/- ##
==========================================
+ Coverage 92.02% 93.25% +1.22%
==========================================
Files 8 8
Lines 163 163
Branches 29 29
==========================================
+ Hits 150 152 +2
+ Misses 13 11 -2
Continue to review full report at Codecov.
|
@@ -30,6 +30,18 @@ describe('IteratorWithOperators', () => { | |||
assert.equal(iterator.next().done, true) | |||
}) | |||
}) | |||
describe('flatten', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test seems to be the exact same as in flatten.test.ts, so I don't understand the purpose? All the other tests in this file do not have tests in external files because they are implemented on the instance itself instead of external classes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main point for myself was to make sure that the type inference matches appropriately. Otherwise, it's just a smoke test that improves coverage. Perhaps it would be best to define the tests in a way to use them in both calling contexts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Let's leave this out for now to not duplicate code. Type inference should be tested with https://github.com/Microsoft/dtslint but I don't have that set up yet.
In the future I would see this library use functions like RxJS instead of prototype methods so that would eliminate the coverage concerns.
@felixfbecker is this PR waiting for something else? |
@cojack please read the discussion above. |
@cojack thanks for the reminder! i forgot i had this one open. I'll get to it soon, and I can also set up dtslint or https://www.npmjs.com/package/tsd in a new PR. |
Also add a test for flatten, based on flatten.test.ts