Skip to content

Commit

Permalink
Merge branch 'master' of github.com:selfrefactor/rambda into 8.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Deyan Totev committed Aug 5, 2023
2 parents 6a2f93d + 790a8fd commit fd97c69
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
3 changes: 2 additions & 1 deletion files/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ Notes:
*/
// @SINGLE_MARKER
export function anyPass<T, U extends T[]>(predicates: { [K in keyof U]: (x: T) => x is U[K]; }): (input: T) => input is U[number];
export function anyPass<T>(predicates: ((x: T) => boolean)[]): (input: T) => boolean;
export function anyPass<T>(predicates: ((...inputs: T[]) => boolean)[]): (...inputs: T[]) => boolean;

Expand All @@ -415,7 +416,7 @@ Notes:
*/
// @SINGLE_MARKER
export function append<T>(x: T, list: T[]): T[];
export function append<T>(x: T): <T>(list: T[]) => T[];
export function append<T>(x: T): (list: T[]) => T[];

/*
Method: applySpec
Expand Down
15 changes: 15 additions & 0 deletions source/anyPass-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,19 @@ describe('anyPass', () => {
const filtered2 = xs.filter(pred)
filtered2 // $ExpectType number[]
})
it('functions as a type guard', () => {
const isString = (x: unknown): x is string => typeof x === 'string';
const isNumber = (x: unknown): x is number => typeof x === 'number';
const isBoolean = (x: unknown): x is boolean => typeof x === 'boolean';

const isStringNumberOrBoolean = anyPass([isString, isNumber, isBoolean]);

isStringNumberOrBoolean // $ExpectType (input: unknown) => input is string | number | boolean

const aValue: unknown = 1;

if (isStringNumberOrBoolean(aValue)) {
aValue // $ExpectType string | number | boolean
}
})
})
6 changes: 4 additions & 2 deletions source/append-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ const list = [1, 2, 3]
describe('R.append', () => {
it('happy', () => {
const result = append(4, list)

result // $ExpectType number[]
})

it('curried', () => {
const result = append(4)(list)
const curried = append(4)
curried // $ExpectType (list: number[]) => number[]

const result = curried(list)
result // $ExpectType number[]
})
})
5 changes: 1 addition & 4 deletions source/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
"lib": ["es2015", "dom"],
"module": "esnext",
"noEmit": true,
"noImplicitAny": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"skipLibCheck": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"strict": true,
"target": "es2015",
"paths": { "rambda": ["../files/index.d.ts"], "ramda": ["../node_modules/types-ramda/es/index.d.ts"] }
}
Expand Down

0 comments on commit fd97c69

Please sign in to comment.