Skip to content

Commit

Permalink
improve getter_setter typing
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 committed Feb 4, 2020
1 parent b20a04d commit 61ab22b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/plugins/kibana_utils/common/create_getter_setter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export type Get<T> = () => T;
export type Set<T> = (value: T) => void;

export const createGetterSetter = <T>(name: string): [Get<T>, Set<T>] => {
let value: T;
let value: T | undefined;

const get: Get<T> = () => {
if (!value) throw new Error(`${name} was not set.`);
if (value === undefined) throw new Error(`${name} was not set.`);
return value;
};

Expand Down

0 comments on commit 61ab22b

Please sign in to comment.