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

Return type of get method in CacheAdapter should also allow 'undefined' #5199

Closed
5 tasks done
SnowMarble opened this issue Feb 1, 2024 · 2 comments · Fixed by #5200
Closed
5 tasks done

Return type of get method in CacheAdapter should also allow 'undefined' #5199

SnowMarble opened this issue Feb 1, 2024 · 2 comments · Fixed by #5200

Comments

@SnowMarble
Copy link
Contributor

Describe the bug

Currently the type of get method in CacheAdapter is:

get<T = any>(name: string): T | Promise<T> | undefined;

But, as non-promise return type allows undefined, I think Promise return type also needs to allow undefined.

get<T = any>(name: string): T | Promise<T | undefined> | undefined;

Reproduction

// Type error: Type 'T | undefined' is not assignable to type 'T'
async get<T = unknown>(name: string): Promise<T | undefined> {
  // rest of the code
}

What driver are you using?

None

MikroORM version

6.0.2

Node.js version

Bun v1.0.25

Operating system

No response

Validations

@B4nan
Copy link
Member

B4nan commented Feb 1, 2024

PR welcome

@SnowMarble
Copy link
Contributor Author

gladly! I just handle this one.

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 a pull request may close this issue.

2 participants