From ac6de8756f7f611ad31713a6395247113f85a4c3 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Fri, 12 Jul 2024 15:15:22 +0000 Subject: [PATCH] Add wrong submittion doc (#16) copied from https://github.com/go-gitea/gitea/pull/31521/files#diff-9b5d4cdddaeeb1b9a0f6aab7ea1964c5e59c7823d9966229c387a3f6a107b9c6 Contributor: @silverwind Reviewed-on: https://gitea.com/gitea/docs/pulls/16 Reviewed-by: techknowlogick Co-authored-by: Lunny Xiao Co-committed-by: Lunny Xiao --- docs/contributing/guidelines-frontend.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/contributing/guidelines-frontend.md b/docs/contributing/guidelines-frontend.md index db0fc460..7a1312e5 100644 --- a/docs/contributing/guidelines-frontend.md +++ b/docs/contributing/guidelines-frontend.md @@ -1,6 +1,5 @@ --- date: "2021-10-13T16:00:00+02:00" -title: "Guidelines for Frontend Development" slug: "guidelines-frontend" sidebar_position: 30 aliases: @@ -71,6 +70,22 @@ We use htmx for simple interactions. You can see an example for simple interacti Although mixing different frameworks is discouraged, it should also work if the mixing is necessary and the code is well-designed and maintainable. +### Typescript + +Gitea is in the process of migrating to type-safe Typescript. Here are some specific guidelines regarding Typescript in the codebase: + +#### Use type aliases instead of interfaces + +Prefer to use type aliases because they can represent any type and are generally more flexible to use than interfaces. + +#### Use separate type imports + +We use `verbatimModuleSyntax` so type and non-type imports from the same file must be split into two `import type` statements. This enables the typescript compiler to completely eliminate the type import statements during compilation. + +#### Use `@ts-expect-error` instead of `@ts-ignore` + +Both annotations should be avoided, but if you have to use them, use `@ts-expect-error` because it will not leave ineffective statements after the issue is fixed. + ### `async` Functions Only mark a function as `async` if and only if there are `await` calls