-
Notifications
You must be signed in to change notification settings - Fork 154
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
Labels
Comments
May I try this issue? |
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]>
While #2125 adds type annotations in the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The text was updated successfully, but these errors were encountered: