Skip to content

Commit fa5ae20

Browse files
Merge pull request DefinitelyTyped#23509 from biern/master
[ramda] Pass strictNullChecks, defaultTo should not return `undefined`
2 parents 15d417b + 45add58 commit fa5ae20

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

types/ramda/index.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ declare namespace R {
201201
* A function that returns the first argument if it's falsy otherwise the second argument. Note that this is
202202
* NOT short-circuited, meaning that if expressions are passed they are both evaluated.
203203
*/
204-
and<T extends { and?: ((...a: any[]) => any); } | number | boolean | string>(fn1: T, val2: any): boolean;
205-
and<T extends { and?: ((...a: any[]) => any); } | number | boolean | string>(fn1: T): (val2: any) => boolean;
204+
and<T extends { and?: ((...a: any[]) => any); } | number | boolean | string | null>(fn1: T, val2: any): boolean;
205+
and<T extends { and?: ((...a: any[]) => any); } | number | boolean | string | null>(fn1: T): (val2: any) => boolean;
206206

207207
/**
208208
* Returns true if at least one of elements of the list match the predicate, false otherwise.
@@ -474,8 +474,8 @@ declare namespace R {
474474
* Returns the second argument if it is not null or undefined. If it is null or undefined, the
475475
* first (default) argument is returned.
476476
*/
477-
defaultTo<T, U>(a: T, b: U): T | U;
478-
defaultTo<T>(a: T): <U>(b: U) => T | U;
477+
defaultTo<T, U>(a: T, b: U | null | undefined): T | U;
478+
defaultTo<T>(a: T): <U>(b: U | null | undefined) => T | U;
479479

480480
/**
481481
* Makes a descending comparator function out of a function that returns a value that can be compared with < and >.

types/ramda/ramda-tests.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ R.times(i, 5);
415415
*/
416416
() => {
417417
function mergeThree(a: number, b: number, c: number): number[] {
418-
return ([]).concat(a, b, c);
418+
return (new Array<number>()).concat(a, b, c);
419419
}
420420

421421
mergeThree(1, 2, 3); // => [1, 2, 3]
@@ -2249,6 +2249,12 @@ class Rectangle {
22492249
defaultTo42(null); // => 42
22502250
defaultTo42(undefined); // => 42
22512251
defaultTo42("Ramda"); // => 'Ramda'
2252+
2253+
const valueOrUndefined = 2 as number | undefined;
2254+
defaultTo42(valueOrUndefined) - 2; // => 0
2255+
2256+
const valueOrNull = 2 as number | null;
2257+
defaultTo42(valueOrNull) - 2; // => 0
22522258
};
22532259

22542260
() => {
@@ -2314,7 +2320,7 @@ class Why {
23142320
const x0: boolean = R.or(false, true); // => false
23152321
const x1: number | any[] = R.or(0, []); // => []
23162322
const x2: number | any[] = R.or(0)([]); // => []
2317-
const x3: string = R.or(null, ""); // => ''
2323+
const x3: string | null = R.or(null, ""); // => ''
23182324

23192325
const why = new Why(true);
23202326
why.or(true);

types/ramda/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
],
88
"noImplicitAny": true,
99
"noImplicitThis": false,
10-
"strictNullChecks": false,
10+
"strictNullChecks": true,
1111
"strictFunctionTypes": false,
1212
"baseUrl": "../",
1313
"typeRoots": [
@@ -22,4 +22,4 @@
2222
"index.d.ts",
2323
"ramda-tests.ts"
2424
]
25-
}
25+
}

0 commit comments

Comments
 (0)