mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 19:07:08 +00:00
[@types/lodash] _.chain().get() shorthand for empty array default (#35497)
* _.chain().get() shorthand for empty array default * add tests for lodash _.chain.get(x, []) shorthand * linting fix & better fallback * use explicit never[] type and add better test of chained _.get() * use never[] in _.chain().get() fallback
This commit is contained in:
parent
08081f49e9
commit
49245ed7e4
4
types/lodash/ts3.1/common/object.d.ts
vendored
4
types/lodash/ts3.1/common/object.d.ts
vendored
@ -1122,6 +1122,10 @@ declare module "../index" {
|
||||
* @see _.get
|
||||
*/
|
||||
get<TKey extends keyof T>(path: TKey | [TKey]): ExpChain<T[TKey]>;
|
||||
/**
|
||||
* @see _.get
|
||||
*/
|
||||
get<TKey extends keyof T>(path: TKey | [TKey], defaultValue: never[]): T[TKey] extends any[] ? ExpChain<Exclude<T[TKey], undefined>> : ExpChain<Exclude<T[TKey], undefined> | never[]>;
|
||||
/**
|
||||
* @see _.get
|
||||
*/
|
||||
|
||||
@ -5201,6 +5201,7 @@ fp.now(); // $ExpectType number
|
||||
_.chain({ a: undefined }).get("a"); // $ExpectType never
|
||||
_.chain({ a: value }).get("a", defaultValue); // $ExpectType StringChain | PrimitiveChain<false> | PrimitiveChain<true>
|
||||
_.chain({ a: undefined }).get("a", defaultValue); // $ExpectType PrimitiveChain<false> | PrimitiveChain<true>
|
||||
_.chain({ a: [1] }).get("a", []).map((val) => val.toFixed()); // $ExpectType CollectionChain<string>
|
||||
|
||||
fp.get(Symbol.iterator, []); // $ExpectType any
|
||||
fp.get(Symbol.iterator)([]); // $ExpectType any
|
||||
|
||||
Loading…
Reference in New Issue
Block a user