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

[Bug]: Type of loader should not allow to return undefined #10239

Closed
jer-sen opened this issue Mar 21, 2023 · 4 comments · Fixed by #10267
Closed

[Bug]: Type of loader should not allow to return undefined #10239

jer-sen opened this issue Mar 21, 2023 · 4 comments · Fixed by #10267
Labels

Comments

@jer-sen
Copy link

jer-sen commented Mar 21, 2023

What version of React Router are you using?

6.8.2

Steps to Reproduce

Write a function that return undefined or nothing in a loader of a route.

Expected Behavior

Type Script error.

This type

/**
 * Route loader function signature
 */
export interface LoaderFunction {
    (args: LoaderFunctionArgs): Promise<Response> | Response | Promise<any> | any;
}

should be rewritten

/**
 * Route loader function signature
 */
export interface LoaderFunction {
    (args: LoaderFunctionArgs): Promise<Response> | Response | Promise<string | number | boolean | symbol | object | null> | string | number | boolean | symbol | object | null;
}

Actual Behavior

No TS error, and so there will be an error at runtime.

@jer-sen jer-sen added the bug label Mar 21, 2023
@timdorr
Copy link
Member

timdorr commented Mar 21, 2023

We can use NonNullable instead.

@brophdawg11
Copy link
Contributor

brophdawg11 commented Apr 21, 2023

Closed in #10267. This will be available when React Router 6.11 is released.

@brophdawg11 brophdawg11 removed their assignment Apr 21, 2023
@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version 6.11.0-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version 6.11.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@brophdawg11 brophdawg11 removed the awaiting release This issue have been fixed and will be released soon label Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants