Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
node-version: [ '22', '23' ]
node-version: [ '22', '24' ]

steps:
- uses: actions/checkout@v2
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
10.3.1
10.3.3

- Fix wrong typing for `R.reject` - [Issue #779](https://github.com/selfrefactor/rambda/issues/779)

- Improve `R.pick` to not allow non-existing keys as input.

10.3.2

- Fix issue with wrong order of inputs in `R.createObjectFromKeys` - [Issue #779](https://github.com/selfrefactor/rambda/issues/779)

Expand Down
65 changes: 36 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5885,7 +5885,7 @@ describe('R.lastIndexOf', () => {
```typescript

map<T extends IterableContainer, U>(
fn: (value: T[number], index: number) => U,
fn: (value: T[number], index: number) => U,
): (data: T) => Mapped<T, U>
```

Expand All @@ -5911,21 +5911,11 @@ const result = R.map(fn)(iterable),

```typescript
map<T extends IterableContainer, U>(
fn: (value: T[number], index: number) => U,
fn: (value: T[number], index: number) => U,
): (data: T) => Mapped<T, U>;
map<T extends IterableContainer, U>(
fn: (value: T[number]) => U,
fn: (value: T[number]) => U,
): (data: T) => Mapped<T, U>;
map<T extends IterableContainer, U>(
fn: (value: T[number], index: number) => U,
data: T
) : Mapped<T, U>;
map<T extends IterableContainer, U>(
fn: (value: T[number]) => U,
data: T
) : Mapped<T, U>;
...
...
```

</details>
Expand Down Expand Up @@ -5979,7 +5969,7 @@ import { map, pipe } from 'rambda'

const list = [1, 2, 3]

it('R.map', () => {
it('R.map - within pipe', () => {
const result = pipe(
list,
x => x,
Expand All @@ -5990,6 +5980,20 @@ it('R.map', () => {
)
result // $ExpectType string[]
})

it('R.map - without pipe', () => {
map(x => {
x // $ExpectType unknown
})([1, 2, 3])
})

it('R.map - without pipe but explicitly typed', () => {
const result = map<number[], string>(x => {
x // $ExpectType number
return String(x)
})([1, 2, 3])
result // $ExpectType string[]
})
```

</details>
Expand Down Expand Up @@ -8435,7 +8439,7 @@ export function permutations(inputArray) {

```typescript

pick<K extends PropertyKey>(propsToPick: K[]): <T>(input: T) => MergeTypes<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>
pick<K extends PropertyKey>(propsToPick: K[]): <T extends Partial<Record<K, any>>>(input: K extends keyof T ? T : never) => MergeTypes<Pick<T, K>>
```

It returns a partial copy of an `input` containing only `propsToPick` properties.
Expand Down Expand Up @@ -8478,8 +8482,8 @@ const expected = [
<summary>All TypeScript definitions</summary>

```typescript
pick<K extends PropertyKey>(propsToPick: K[]): <T>(input: T) => MergeTypes<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>;
pick<S extends string>(propsToPick: S): <T>(input: T) => MergeTypes<Pick<T, Exclude<keyof T, Exclude<keyof T, ElementOf<PickStringToPickPath<S>>>>>>;
pick<K extends PropertyKey>(propsToPick: K[]): <T extends Partial<Record<K, any>>>(input: K extends keyof T ? T : never) => MergeTypes<Pick<T, K>>;
pick<S extends string, Keys extends PickStringToPickPath<S>>(propsToPick: S): <T extends Partial<Record<ElementOf<Keys>, any>>>(input: ElementOf<Keys> extends keyof T ? T : never) => ElementOf<Keys> extends keyof T ? MergeTypes<Pick<T, ElementOf<Keys>>> : never;
```

</details>
Expand Down Expand Up @@ -8567,15 +8571,19 @@ const input = { a: 'foo', c: 3 }

describe('R.pick', () => {
it('with string as input', () => {
const result = pipe(input, pick('a,c,b,o'))
const result = pipe(input, pick('a,c'))
result.a // $ExpectType string
result.c // $ExpectType number
})
it('with array as input', () => {
const result = pipe(input, pick(['a', 'c']))
const result = pipe(input, pick(['a', 'c']))
result.a // $ExpectType string
result.c // $ExpectType number
})
it('throws error if some keys do not exist', () => {
// @ts-expect-error
pipe(input, pick('a,c,b,o'))
})
})
```

Expand Down Expand Up @@ -9790,9 +9798,8 @@ it('R.reduce', () => {
```typescript

reject<T>(
predicate: (value: T) => boolean,
list: T[],
): T[]
predicate: BooleanConstructor,
): (list: readonly T[]) => ("" | null | undefined | false | 0)[]
```

It has the opposite effect of `R.filter`.
Expand All @@ -9816,10 +9823,6 @@ const result = [
<summary>All TypeScript definitions</summary>

```typescript
reject<T>(
predicate: (value: T) => boolean,
list: T[],
): T[];
reject<T>(
predicate: BooleanConstructor,
): (list: readonly T[]) => ("" | null | undefined | false | 0)[];
Expand All @@ -9829,8 +9832,6 @@ reject<T>(
reject<T>(
predicate: (value: T) => boolean,
): (list: T[]) => T[];
...
...
```

</details>
Expand Down Expand Up @@ -13541,7 +13542,13 @@ describe('R.zipWith', () => {

## ❯ CHANGELOG

10.3.1
10.3.3

- Fix wrong typing for `R.reject` - [Issue #779](https://github.com/selfrefactor/rambda/issues/779)

- Improve `R.pick` to not allow non-existing keys as input.

10.3.2

- Fix issue with wrong order of inputs in `R.createObjectFromKeys` - [Issue #779](https://github.com/selfrefactor/rambda/issues/779)

Expand Down
65 changes: 36 additions & 29 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5885,7 +5885,7 @@ describe('R.lastIndexOf', () => {
```typescript

map<T extends IterableContainer, U>(
fn: (value: T[number], index: number) => U,
fn: (value: T[number], index: number) => U,
): (data: T) => Mapped<T, U>
```

Expand All @@ -5911,21 +5911,11 @@ const result = R.map(fn)(iterable),

```typescript
map<T extends IterableContainer, U>(
fn: (value: T[number], index: number) => U,
fn: (value: T[number], index: number) => U,
): (data: T) => Mapped<T, U>;
map<T extends IterableContainer, U>(
fn: (value: T[number]) => U,
fn: (value: T[number]) => U,
): (data: T) => Mapped<T, U>;
map<T extends IterableContainer, U>(
fn: (value: T[number], index: number) => U,
data: T
) : Mapped<T, U>;
map<T extends IterableContainer, U>(
fn: (value: T[number]) => U,
data: T
) : Mapped<T, U>;
...
...
```

</details>
Expand Down Expand Up @@ -5979,7 +5969,7 @@ import { map, pipe } from 'rambda'

const list = [1, 2, 3]

it('R.map', () => {
it('R.map - within pipe', () => {
const result = pipe(
list,
x => x,
Expand All @@ -5990,6 +5980,20 @@ it('R.map', () => {
)
result // $ExpectType string[]
})

it('R.map - without pipe', () => {
map(x => {
x // $ExpectType unknown
})([1, 2, 3])
})

it('R.map - without pipe but explicitly typed', () => {
const result = map<number[], string>(x => {
x // $ExpectType number
return String(x)
})([1, 2, 3])
result // $ExpectType string[]
})
```

</details>
Expand Down Expand Up @@ -8435,7 +8439,7 @@ export function permutations(inputArray) {

```typescript

pick<K extends PropertyKey>(propsToPick: K[]): <T>(input: T) => MergeTypes<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>
pick<K extends PropertyKey>(propsToPick: K[]): <T extends Partial<Record<K, any>>>(input: K extends keyof T ? T : never) => MergeTypes<Pick<T, K>>
```

It returns a partial copy of an `input` containing only `propsToPick` properties.
Expand Down Expand Up @@ -8478,8 +8482,8 @@ const expected = [
<summary>All TypeScript definitions</summary>

```typescript
pick<K extends PropertyKey>(propsToPick: K[]): <T>(input: T) => MergeTypes<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>;
pick<S extends string>(propsToPick: S): <T>(input: T) => MergeTypes<Pick<T, Exclude<keyof T, Exclude<keyof T, ElementOf<PickStringToPickPath<S>>>>>>;
pick<K extends PropertyKey>(propsToPick: K[]): <T extends Partial<Record<K, any>>>(input: K extends keyof T ? T : never) => MergeTypes<Pick<T, K>>;
pick<S extends string, Keys extends PickStringToPickPath<S>>(propsToPick: S): <T extends Partial<Record<ElementOf<Keys>, any>>>(input: ElementOf<Keys> extends keyof T ? T : never) => ElementOf<Keys> extends keyof T ? MergeTypes<Pick<T, ElementOf<Keys>>> : never;
```

</details>
Expand Down Expand Up @@ -8567,15 +8571,19 @@ const input = { a: 'foo', c: 3 }

describe('R.pick', () => {
it('with string as input', () => {
const result = pipe(input, pick('a,c,b,o'))
const result = pipe(input, pick('a,c'))
result.a // $ExpectType string
result.c // $ExpectType number
})
it('with array as input', () => {
const result = pipe(input, pick(['a', 'c']))
const result = pipe(input, pick(['a', 'c']))
result.a // $ExpectType string
result.c // $ExpectType number
})
it('throws error if some keys do not exist', () => {
// @ts-expect-error
pipe(input, pick('a,c,b,o'))
})
})
```

Expand Down Expand Up @@ -9790,9 +9798,8 @@ it('R.reduce', () => {
```typescript

reject<T>(
predicate: (value: T) => boolean,
list: T[],
): T[]
predicate: BooleanConstructor,
): (list: readonly T[]) => ("" | null | undefined | false | 0)[]
```

It has the opposite effect of `R.filter`.
Expand All @@ -9816,10 +9823,6 @@ const result = [
<summary>All TypeScript definitions</summary>

```typescript
reject<T>(
predicate: (value: T) => boolean,
list: T[],
): T[];
reject<T>(
predicate: BooleanConstructor,
): (list: readonly T[]) => ("" | null | undefined | false | 0)[];
Expand All @@ -9829,8 +9832,6 @@ reject<T>(
reject<T>(
predicate: (value: T) => boolean,
): (list: T[]) => T[];
...
...
```

</details>
Expand Down Expand Up @@ -13541,7 +13542,13 @@ describe('R.zipWith', () => {

## ❯ CHANGELOG

10.3.1
10.3.3

- Fix wrong typing for `R.reject` - [Issue #779](https://github.com/selfrefactor/rambda/issues/779)

- Improve `R.pick` to not allow non-existing keys as input.

10.3.2

- Fix issue with wrong order of inputs in `R.createObjectFromKeys` - [Issue #779](https://github.com/selfrefactor/rambda/issues/779)

Expand Down
20 changes: 4 additions & 16 deletions files/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -986,19 +986,11 @@ Notes: This function doesn't work with objects (use R.mapObject instead)
*/
// @SINGLE_MARKER
export function map<T extends IterableContainer, U>(
fn: (value: T[number], index: number) => U,
fn: (value: T[number], index: number) => U,
): (data: T) => Mapped<T, U>;
export function map<T extends IterableContainer, U>(
fn: (value: T[number]) => U,
fn: (value: T[number]) => U,
): (data: T) => Mapped<T, U>;
export function map<T extends IterableContainer, U>(
fn: (value: T[number], index: number) => U,
data: T
) : Mapped<T, U>;
export function map<T extends IterableContainer, U>(
fn: (value: T[number]) => U,
data: T
) : Mapped<T, U>;

/*
Method: mapObject
Expand Down Expand Up @@ -1886,8 +1878,8 @@ Categories: Object
Notes: pipe
*/
// @SINGLE_MARKER
export function pick<K extends PropertyKey>(propsToPick: K[]): <T>(input: T) => MergeTypes<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>;
export function pick<S extends string>(propsToPick: S): <T>(input: T) => MergeTypes<Pick<T, Exclude<keyof T, Exclude<keyof T, ElementOf<PickStringToPickPath<S>>>>>>;
export function pick<K extends PropertyKey>(propsToPick: K[]): <T extends Partial<Record<K, any>>>(input: K extends keyof T ? T : never) => MergeTypes<Pick<T, K>>;
export function pick<S extends string, Keys extends PickStringToPickPath<S>>(propsToPick: S): <T extends Partial<Record<ElementOf<Keys>, any>>>(input: ElementOf<Keys> extends keyof T ? T : never) => ElementOf<Keys> extends keyof T ? MergeTypes<Pick<T, ElementOf<Keys>>> : never;

/*
Method: pipe
Expand Down Expand Up @@ -2393,10 +2385,6 @@ Notes:

*/
// @SINGLE_MARKER
export function reject<T>(
predicate: (value: T) => boolean,
list: T[],
): T[];
export function reject<T>(
predicate: BooleanConstructor,
): (list: readonly T[]) => ("" | null | undefined | false | 0)[];
Expand Down
Loading