import { of, Observable } from 'rxjs'; import { publish } from 'rxjs/operators'; it('should support empty parameter', () => { // Here, TypeScript versions 3.1 and earlier infer Observable. However, // the next version infers Observable. It's not possible to specify // an upper bound for the TypeScript version used by dtslint, so an // expectation cannot be applied. const a = of(1, 2, 3).pipe(publish()); // $ExpectType Observable }); it('should infer when type is specified', () => { const a = of(1, 2, 3).pipe(publish()); // $ExpectType Observable }); it('should infer correctly with parameter', () => { const a = of(1, 2, 3).pipe(publish(x => x)); // $ExpectType Observable const b = of('a', 'b', 'c').pipe(publish(x => x)); // $ExpectType Observable }); it('should enforce type on selector', () => { const a = of(1, 2, 3).pipe(publish((x: Observable) => x)); // $ExpectError }); it('should support union types in selector', () => { const a = of(1, 2, 3).pipe(publish(() => Math.random() > 0.5 ? of(123) : of('test'))); // $ExpectType Observable });