Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Two TS linting errors in `main.ts`

已關閉
#34,267 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@Hangell 已經在處理了。

開始於 2026年10月7日。

  • #34268 來自 @Hangell —— 未關閉

評估

難度
1/5
預估耗時
1 小時以內
新手友好度
45/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
typescript

研究方向

Find the ng new workspace template that emits src/main.ts (the angular-cli schematics workspace files, ending in .ts.template) and update the .catch callback to the block-bodied err: unknown form shown in the issue. Verify by generating a project with ng new, adding @angular-eslint/schematics, switching to tseslint.configs.strictTypeChecked with typed linting parser options, and running ng lint — done means both rules pass. Note an open pull request (#34268) already targets this issue, so check its status before starting.

由索引模型根據 Issue 內容生成。

描述

area: @schematics/angular
Command

new

Is this a regression?
  • Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was

No response

Description

ng new generates boilerplate that contains two linting errors. They appear when linting with type information:

<path>\src\main.ts
  6:11  error  Prefer the safe `: unknown` for a `catch` callback variable                                                         @typescript-eslint/use-unknown-in-catch-callback-variable
  6:19  error  Returning a void expression from an arrow function shorthand is forbidden. Please add braces to the arrow function  @typescript-eslint/no-confusing-void-expression

The two issues can be fixed by changing the offending code to:

bootstrapApplication(App, appConfig).catch((err: unknown) => {
  console.error(err);
});

See the ts-eslint doc pages for no-confusing-void-expression and use-unknown-in-catch-callback-variable.

Minimal Reproduction
  1. Generate a new project with ng new.
  2. Run ng add @angular-eslint/schematics to add eslint.
  3. In eslint.config.js, change tseslintConfigs.recommended to tseslint.configs.strictTypeChecked.
  4. Add languageOptions.parserOptions as described in the ts-eslint docs.
  5. Run ng lint.
Exception or Error

Your Environment
Angular CLI       : 22.0.1
Angular           : 22.0.1
Node.js           : 26.9.0
Package Manager   : npm 11.16.0
Operating System  : win32 x64
Anything else relevant?

TS 7.1 is expected to bring a faster typed linting API, so typed linting will become even more common.

主要語言
TypeScript
星號
27k
分支
11.8k
平均合併
1 天 2 分鐘
30 天內合併 PR
168

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

angular/angular-cli 的其他 Issue

查看 angular/angular-cli 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。