Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix return type for getOrSet for a promise factory #493

Merged
merged 1 commit into from
Aug 16, 2019

Conversation

agubler
Copy link
Member

@agubler agubler commented Aug 16, 2019

Type: bug

The following has been addressed in the PR:

Description:

Fix the getOrSet typings for a promise factory to return undefined | T, with T being the return type of the promise or the generic passed to getOrSet.

Before:

/* Type: undefined */
icache.getOrSet<string>('test', () => Promise.resolve());
/* Type: undefined */
icache.getOrSet<string>('test', () => new Promise<string>(() => {}));
/* Type: undefined */
icache.getOrSet('test', () => new Promise<string>(() => {}));

After:

/* Type: string | undefined */
icache.getOrSet<string>('test', () => Promise.resolve());
/* Type: string | undefined */
icache.getOrSet<string>('test', () => new Promise<string>(() => {}));
/* Type: string | undefined */
icache.getOrSet('test', () => new Promise<string>(() => {}));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants