diff --git a/api_guard/dist/types/index.d.ts b/api_guard/dist/types/index.d.ts index 02cf3faf91..7c8e7e2ec9 100644 --- a/api_guard/dist/types/index.d.ts +++ b/api_guard/dist/types/index.d.ts @@ -330,7 +330,7 @@ export declare type PartialObserver = NextObserver | ErrorObserver | Co export declare function partition(source: ObservableInput, predicate: (this: A, value: T, index: number) => boolean, thisArg: A): [Observable, Observable]; export declare function partition(source: ObservableInput, predicate: (value: T, index: number) => boolean): [Observable, Observable]; -export declare function pipe(): UnaryFunction; +export declare function pipe(): typeof identity; export declare function pipe(fn1: UnaryFunction): UnaryFunction; export declare function pipe(fn1: UnaryFunction, fn2: UnaryFunction): UnaryFunction; export declare function pipe(fn1: UnaryFunction, fn2: UnaryFunction, fn3: UnaryFunction): UnaryFunction; diff --git a/spec-dtslint/util/pipe-spec.ts b/spec-dtslint/util/pipe-spec.ts index b063348b47..f4d30d1279 100644 --- a/spec-dtslint/util/pipe-spec.ts +++ b/spec-dtslint/util/pipe-spec.ts @@ -22,7 +22,7 @@ function a(input: I, output: O): UnaryFuncti } it('should infer unknown for no arguments', () => { - const o = pipe(); // $ExpectType UnaryFunction + const o = pipe(); // $ExpectType (x: T) => T }); it('should infer for 1 argument', () => { diff --git a/src/internal/util/pipe.ts b/src/internal/util/pipe.ts index f9c2a724c9..f68ae42622 100644 --- a/src/internal/util/pipe.ts +++ b/src/internal/util/pipe.ts @@ -2,17 +2,73 @@ import { identity } from './identity'; import { UnaryFunction } from '../types'; /* tslint:disable:max-line-length */ -export function pipe(): UnaryFunction; +export function pipe(): typeof identity; export function pipe(fn1: UnaryFunction): UnaryFunction; export function pipe(fn1: UnaryFunction, fn2: UnaryFunction): UnaryFunction; export function pipe(fn1: UnaryFunction, fn2: UnaryFunction, fn3: UnaryFunction): UnaryFunction; -export function pipe(fn1: UnaryFunction, fn2: UnaryFunction, fn3: UnaryFunction, fn4: UnaryFunction): UnaryFunction; -export function pipe(fn1: UnaryFunction, fn2: UnaryFunction, fn3: UnaryFunction, fn4: UnaryFunction, fn5: UnaryFunction): UnaryFunction; -export function pipe(fn1: UnaryFunction, fn2: UnaryFunction, fn3: UnaryFunction, fn4: UnaryFunction, fn5: UnaryFunction, fn6: UnaryFunction): UnaryFunction; -export function pipe(fn1: UnaryFunction, fn2: UnaryFunction, fn3: UnaryFunction, fn4: UnaryFunction, fn5: UnaryFunction, fn6: UnaryFunction, fn7: UnaryFunction): UnaryFunction; -export function pipe(fn1: UnaryFunction, fn2: UnaryFunction, fn3: UnaryFunction, fn4: UnaryFunction, fn5: UnaryFunction, fn6: UnaryFunction, fn7: UnaryFunction, fn8: UnaryFunction): UnaryFunction; -export function pipe(fn1: UnaryFunction, fn2: UnaryFunction, fn3: UnaryFunction, fn4: UnaryFunction, fn5: UnaryFunction, fn6: UnaryFunction, fn7: UnaryFunction, fn8: UnaryFunction, fn9: UnaryFunction): UnaryFunction; -export function pipe(fn1: UnaryFunction, fn2: UnaryFunction, fn3: UnaryFunction, fn4: UnaryFunction, fn5: UnaryFunction, fn6: UnaryFunction, fn7: UnaryFunction, fn8: UnaryFunction, fn9: UnaryFunction, ...fns: UnaryFunction[]): UnaryFunction; +export function pipe( + fn1: UnaryFunction, + fn2: UnaryFunction, + fn3: UnaryFunction, + fn4: UnaryFunction +): UnaryFunction; +export function pipe( + fn1: UnaryFunction, + fn2: UnaryFunction, + fn3: UnaryFunction, + fn4: UnaryFunction, + fn5: UnaryFunction +): UnaryFunction; +export function pipe( + fn1: UnaryFunction, + fn2: UnaryFunction, + fn3: UnaryFunction, + fn4: UnaryFunction, + fn5: UnaryFunction, + fn6: UnaryFunction +): UnaryFunction; +export function pipe( + fn1: UnaryFunction, + fn2: UnaryFunction, + fn3: UnaryFunction, + fn4: UnaryFunction, + fn5: UnaryFunction, + fn6: UnaryFunction, + fn7: UnaryFunction +): UnaryFunction; +export function pipe( + fn1: UnaryFunction, + fn2: UnaryFunction, + fn3: UnaryFunction, + fn4: UnaryFunction, + fn5: UnaryFunction, + fn6: UnaryFunction, + fn7: UnaryFunction, + fn8: UnaryFunction +): UnaryFunction; +export function pipe( + fn1: UnaryFunction, + fn2: UnaryFunction, + fn3: UnaryFunction, + fn4: UnaryFunction, + fn5: UnaryFunction, + fn6: UnaryFunction, + fn7: UnaryFunction, + fn8: UnaryFunction, + fn9: UnaryFunction +): UnaryFunction; +export function pipe( + fn1: UnaryFunction, + fn2: UnaryFunction, + fn3: UnaryFunction, + fn4: UnaryFunction, + fn5: UnaryFunction, + fn6: UnaryFunction, + fn7: UnaryFunction, + fn8: UnaryFunction, + fn9: UnaryFunction, + ...fns: UnaryFunction[] +): UnaryFunction; /* tslint:enable:max-line-length */ export function pipe(...fns: Array>): UnaryFunction {