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

Explicit return type annotation for TypeScript functions #2002

Open
ckcherry23 opened this issue May 8, 2023 · 2 comments
Open

Explicit return type annotation for TypeScript functions #2002

ckcherry23 opened this issue May 8, 2023 · 2 comments

Comments

@ckcherry23
Copy link
Member

ckcherry23 commented May 8, 2023

What feature(s) would you like to see in RepoSense

Specify the return type of relevant functions in the frontend codebase. This is important because it can help catch errors early in the development process.

Is the feature request related to a problem?

Currently, many functions on the frontend do not have a return type even after the files were migrated to TypeScript. If we don't specify the return types for functions, TypeScript will try to infer it based on the function's implementation. However, this inference can sometimes be incorrect, leading to unexpected behavior or errors.

By specifying the return type explicitly, we can help TypeScript catch any type errors before the code even runs. Additionally, specifying return types can make the code more readable and self-documenting, as it makes it clear what type of value the function will return.

If possible, describe the solution

For official TypeScript docs on using return types, one can refer to https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#return-type-annotations.

Additional context

Discussed in #1969

@suxiaocha123
Copy link

May I try this issue?

@supermii2 supermii2 self-assigned this Jan 22, 2024
ckcherry23 pushed a commit that referenced this issue Apr 13, 2024
…in *.vue files (#2125)

Many frontend functions lack return types after migration to
TypeScript, which can cause errors due to TypeScript's attempted type
inference being incorrect. Specifying return type explicitly can allow
TypeScript to catch errors before the code is run.

Let us add return type annotations to TypeScript functions within Vue
files.

---------

Co-authored-by: David <[email protected]>
@ckcherry23
Copy link
Member Author

While #2125 adds type annotations in the .vue files, the functions in the raw .ts files still lack return type annotations. Let's add these too in a separate PR so that we can close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: For contributors
Development

No branches or pull requests

3 participants