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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

enum and/or type guard for QueryDslTextQueryType #2122

Open
y-nk opened this issue Jan 22, 2024 · 1 comment
Open

enum and/or type guard for QueryDslTextQueryType #2122

y-nk opened this issue Jan 22, 2024 · 1 comment

Comments

@y-nk
Copy link

y-nk commented Jan 22, 2024

馃殌 Feature Proposal

We have a usecase where we receive/produce string as a type, which should be typed as QueryDslTextQueryType. I would like to have a way in this library (as single source of truth) to produce a QueryDslTextQueryType from a string.

Motivation

It's much better if the guard is produced and maintained tightly with this library.

Example

enum QueryDslTextQueryType {
  // the values of QueryDslTextQueryType union type
}

function isQueryDslTextQueryType(arg: any): arg is QueryDslTextQueryType {
  return Object.values(QueryDslTextQueryType).includes(arg)
}
@JoshMock
Copy link
Member

Seems like this could be an opportunity to generate type guards for most or all types in the whole library. Going to think about this for a bit and see if it's reasonable to implement.

Thanks for the request!

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

No branches or pull requests

2 participants