Skip to content
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

test(dtslint): add dtslint test for scan operator (#4093) #4347

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions spec-dtslint/operators/scan-spec.ts
@@ -0,0 +1,19 @@
import { of } from 'rxjs';
import { scan } from 'rxjs/operators';

it('should enforce parameter', () => {
const a = of(1, 2, 3).pipe(scan()); // $ExpectError
});

it('should infer correctly ', () => {
const a = of(1, 2, 3).pipe(scan((x, y, z) => x + 1)); // $ExpectType Observable<number>
});

it('should infer correctly for accumulator of type array', () => {
const a = of(1, 2, 3).pipe(scan((x: number[], y: number, i: number) => x, [])); // $ExpectType Observable<number[]>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @cartant ,
I have changed the test to identically like reduce. But, I'm not sure about the type expectations you mentioned on the comment above - look like the typings are exactly the same as reduce.
Is this correct?

});

it('should accept seed parameter of the same type', () => {
const a = of(1, 2, 3).pipe(scan((x, y, z) => x + 1, 5)); // $ExpectType Observable<number>
const b = of(1, 2, 3).pipe(scan((x, y, z) => x + 1, '5')); // $ExpectError
});