Skip to content

Conversation

@allansson
Copy link

Please fill in this template.

Copy link

@ankur22 ankur22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done! LGTM 🚀

* @param options
*/
goto(url: string, options?: NavigationOptions): Promise<null | Response>;
goto(url: string, options?: NavigationOptions): Promise<Response | null>;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ordering makes more sense. Is this also idiomatic?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say so, yes.

My gut feeling for how it "should" be is:

  1. Complex, named types
  2. Primitives
  3. null and undefined

For example:

function abc(): Alphabet | string | null

The point is to keep the thing that the user is looking for up front, so that it's easier to find functions that return what you want. And you're unlikely to want to use a function because it returns null or undefined.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The counter-argument is that you should draw attention to the exceptional value (null, undefined or custom error types) to highlight the fact that the function has some special cases that you need to handle.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But what I see most often is that null and undefined go at the end. 🙂

Copy link

@inancgumus inancgumus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work 🙇

@allansson allansson merged commit 832f688 into master-async-browser Jun 5, 2024
@inancgumus inancgumus deleted the async/async-page-api branch November 11, 2025 16:07
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.

3 participants