Skip to content

Commit

Permalink
🤖 Merge PR #69534 [lodash] fix _.has not to be inferred to never on o…
Browse files Browse the repository at this point in the history
…r operator by @Ha-limLee
  • Loading branch information
Ha-limLee committed May 17, 2024
1 parent 1de17c9 commit 4f7cc7d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions types/lodash/common/common.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import _ = require("../index");
// eslint-disable-next-line @definitelytyped/strict-export-declare-modifiers
type GlobalPartial<T> = Partial<T>;
export const uniqueSymbol: unique symbol;
declare module "../index" {
type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
type PartialObject<T> = GlobalPartial<T>;
Expand Down
3 changes: 2 additions & 1 deletion types/lodash/common/object.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ = require("../index");
import { uniqueSymbol } from "./common";
declare module "../index" {
interface LoDashStatic {
/**
Expand Down Expand Up @@ -1327,7 +1328,7 @@ declare module "../index" {
* _.has(other, 'a');
* // => false
*/
has<T, K extends PropertyName>(object: T, path: K): object is T & { [P in K]: P extends keyof T ? T[P] : Record<string, unknown> extends T ? T[keyof T] : unknown};
has<T, K extends PropertyName>(object: T, path: K): object is T & { [P in K]: P extends keyof T ? T[P] : Record<string, unknown> extends T ? T[keyof T] : unknown} & {[uniqueSymbol]: unknown};
has<T>(object: T, path: PropertyPath): boolean;
}
interface LoDashImplicitWrapper<TValue> {
Expand Down
6 changes: 6 additions & 0 deletions types/lodash/lodash-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5481,6 +5481,12 @@ fp.now(); // $ExpectType number
const result: { a: number | string } = record;
record; // $ExpectType Record<string, number | string>
}
const data = {
level: 1,
length: 1,
};
_.has(data, 'level') || !!data.length;

_(abcObject).has(""); // $ExpectType boolean
_(abcObject).has(42); // $ExpectType boolean
_(abcObject).has(["", 42]); // $ExpectType boolean
Expand Down

0 comments on commit 4f7cc7d

Please sign in to comment.