chore: rebase

This commit is contained in:
ecyrbe
2023-02-13 11:17:19 +01:00
parent f6fbed04ad
commit b3854bbc76
3 changed files with 26 additions and 4 deletions

View File

@@ -3,6 +3,10 @@ import { Apply, Fn, MergeArgs, placeholder } from "../core/Core";
export namespace Functions {
export type _ = placeholder;
export interface Identity extends Fn {
output: this["args"][0];
}
interface PipeableApplyPartial<fn extends Fn, partialArgs extends any[]>
extends Fn {
output: Apply<fn, MergeArgs<this["args"], partialArgs>>;
@@ -12,4 +16,22 @@ export namespace Functions {
fn extends Fn,
args extends any[]
> = PipeableApplyPartial<fn, args>;
type ParametersImpl<fn> = fn extends (...args: infer args) => any
? args
: never;
export interface Parameters extends Fn {
output: ParametersImpl<this["args"][0]>;
}
export interface Parameter<N extends number> extends Fn {
output: ParametersImpl<this["args"][0]>[N];
}
type ReturnImpl<fn> = fn extends (...args: any[]) => infer ret ? ret : never;
export interface Return extends Fn {
output: ReturnImpl<this["args"][0]>;
}
}

View File

@@ -3,7 +3,6 @@ import {
PipeRight,
Call,
Fn,
IdentityFn,
Extends,
Call2,
Eval,
@@ -23,14 +22,14 @@ describe("HOTScript", () => {
describe("Functions", () => {
it("Identity", () => {
// check primitives
type res1 = Call<IdentityFn, string>;
type res1 = Call<F.Identity, string>;
// ^?
type tes1 = Expect<Equal<res1, string>>;
type res2 = Call<IdentityFn, undefined>;
type res2 = Call<F.Identity, undefined>;
// ^?
type tes2 = Expect<Equal<res2, undefined>>;
// check unions
type res3 = Call<IdentityFn, string | number>;
type res3 = Call<F.Identity, string | number>;
// ^?
type tes3 = Expect<Equal<res3, string | number>>;
});

View File

@@ -2,6 +2,7 @@
"compilerOptions": {
"module": "ESNext",
"declaration": true,
"esModuleInterop": true,
"target": "ESNext",
"strict": true,
"outDir": "dist/"