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

Auto deduce return error type #3

Open
rathod-sahaab opened this issue Nov 13, 2024 · 0 comments
Open

Auto deduce return error type #3

rathod-sahaab opened this issue Nov 13, 2024 · 0 comments

Comments

@rathod-sahaab
Copy link
Owner

Currently there are two ways of specifying return error types

// 1
export function serviceCreatePost(
	article: string,
): Result<Post, 'InternalServerError' | 'BadRequest'> {}

// 2
export const serviceCreatePostAutoErrorKind = ((article: string) => {}) satisfies (article: string) => Result<Post, IHttpErrorKind>

Notice the second function doesn't explicitly state error kind and thus is easier to work with for large and diverse functions.

But this is a hack and syntax is cumbersome, a real method will only come to fruition after TypeScript/satifies on return type or TypeScript/satisfies on function is resolve until then I am using explicit. Please go show some love to these issues

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

1 participant