diff --git a/snapshots/ramda-tests.ts b/snapshots/ramda-tests.ts index a937cc6..425a057 100644 --- a/snapshots/ramda-tests.ts +++ b/snapshots/ramda-tests.ts @@ -2269,6 +2269,8 @@ import * as R from '../ramda/dist/index'; (m: number) => Promise.resolve(m / 2), R.multiply(5), )(10); + // @dts-jest:fail:snap -> Argument of type '() => number' is not assignable to parameter of type '(v1: {}, v2: {}, v3: {}, v4: {}, v5: {}, v6: {}) => PromiseLike<{}>'. + R.pipeP(() => 1); })(); // @dts-jest:group pluck diff --git a/templates/pipeP.ts b/templates/pipeP.ts index 0d31d4e..f74c5ff 100644 --- a/templates/pipeP.ts +++ b/templates/pipeP.ts @@ -7,6 +7,6 @@ export default create_composition_declarations( max_curry_level, 6, x => x, - x => `PromiseLike<${x}> | ${x}`, + (x, i) => (i === 0 ? `PromiseLike<${x}>` : `PromiseLike<${x}> | ${x}`), x => `PromiseLike<${x}>`, ); diff --git a/templates/utils/create-composition-declarations.ts b/templates/utils/create-composition-declarations.ts index 3c58fd9..809e78d 100644 --- a/templates/utils/create-composition-declarations.ts +++ b/templates/utils/create-composition-declarations.ts @@ -9,11 +9,14 @@ export const create_composition_declarations = ( // istanbul ignore next generate_function_parameter_type: (generic: string) => string = x => x, // istanbul ignore next - generate_function_return_type: (generic: string) => string = x => x, + generate_function_return_type: ( + generic: string, + index: number, + ) => string = x => x, // istanbul ignore next - generate_composed_return_type: ( + generate_composed_return_type = generate_function_return_type as ( generic: string, - ) => string = generate_function_return_type, + ) => string, ) => { const function_names = R.repeat(0, max_function_count).map( (_, index) => `fn${index + 1}`, @@ -81,12 +84,16 @@ export const create_composition_declarations = ( return index === entry_index ? `${function_name}: (${entry_parameters}) => ${generate_function_return_type( return_generic, + index, )}` : `${function_name}: (v: ${generate_function_parameter_type( current_sorted_return_generics[ index + (kind === 'compose' ? 1 : -1) ], - )}) => ${generate_function_return_type(return_generic)}`; + )}) => ${generate_function_return_type( + return_generic, + index, + )}`; }) .join(',')} ): (${entry_parameters}) => ${generate_composed_return_type( diff --git a/tests/__snapshots__/ramda-tests.ts.snap b/tests/__snapshots__/ramda-tests.ts.snap index 2670347..9fe95e5 100644 --- a/tests/__snapshots__/ramda-tests.ts.snap +++ b/tests/__snapshots__/ramda-tests.ts.snap @@ -1091,6 +1091,11 @@ exports[`pipeP R.pipeP( (m: number) => Promise.resolve(m / 2), )(10) 1`] = `"PromiseLike"`; +exports[`pipeP R.pipeP(() => 1) 1`] = ` +"Argument of type '() => number' is not assignable to parameter of type '(v1: {}, v2: {}, v3: {}, v4: {}, v5: {}, v6: {}) => PromiseLike<{}>'. + Type 'number' is not assignable to type 'PromiseLike<{}>'." +`; + exports[`pluck R.pluck( 'value', R.pick(['a'])({ diff --git a/tests/ramda-tests.ts b/tests/ramda-tests.ts index d5ed9d1..53f461c 100644 --- a/tests/ramda-tests.ts +++ b/tests/ramda-tests.ts @@ -2269,6 +2269,8 @@ import * as R from '../ramda/dist/index'; (m: number) => Promise.resolve(m / 2), R.multiply(5), )(10); + // @dts-jest:fail:snap + R.pipeP(() => 1); })(); // @dts-jest:group pluck