diff --git a/spec-dtslint/operators/scan-spec.ts b/spec-dtslint/operators/scan-spec.ts new file mode 100644 index 0000000000..7f11324c9f --- /dev/null +++ b/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 +}); + +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 +}); + +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 + const b = of(1, 2, 3).pipe(scan((x, y, z) => x + 1, '5')); // $ExpectError +});