Skip to content

Commit

Permalink
fix: MapUtil.get return type, to use function overloading
Browse files Browse the repository at this point in the history
  • Loading branch information
elegantcoder committed Jun 18, 2024
1 parent a838d78 commit ec5a3cd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/map-util/map-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export namespace MapUtil {
* @param key
* @param defaultValue
*/
export function get<K, V>(map: Map<K, V>, key: K, defaultValue?: V) {
export function get<K, V>(map: Map<K, V>, key: K): V | undefined;
export function get<K, V>(map: Map<K, V>, key: K, defaultValue: V): V;
export function get<K, V>(map: Map<K, V>, key: K, defaultValue?: V): V | undefined {
const value = map.get(key);
return value === undefined ? defaultValue : value;
}
Expand Down

0 comments on commit ec5a3cd

Please sign in to comment.