You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
The code generated by ng new is designed to comply with TypeScript's strict mode as configured in the generated tsconfig.json, as well as the default configuration provided by @angular-eslint/schematics (tseslint.configs.recommended).
Because third-party linter presets like strictTypeChecked are opt-in, opinionated, and can conflict with other common lint rules (for example, arrow-body-style), we don't tailor the default project templates to satisfy non-default third-party lint configurations. When opting into stricter custom ESLint rulesets after generating a workspace, we recommend running ng lint --fix or updating the generated files to match your preferred ruleset.
@alan-agius4 Fair point; I'm providing a counterargument in case it can be reconsidered.
strictTypeChecked is not a "third-party" preset but a native typescript-eslint preset. It is not supposed to be "opinionated", since there is a separate set of rules for opinionated rules (stylistic and stylisticTypeChecked).
The no-confusing-void-expression error reported is a legit type error. The err => console.error(err) actually returns the result of console.error(err), which returns void. That's why it should be in {}. It does not conflict with arrow-body-style since that's for cases where the function is actually returning something.
angular-automatic-lock-bot commented on Nov 7, 2026
Activity
fix(@schematics/angular): generate main.ts with lint-compatible error…
alan-agius4 commentedon Oct 7, 2026
Thanks for reporting this.
The code generated by
ng newis designed to comply with TypeScript'sstrictmode as configured in the generatedtsconfig.json, as well as the default configuration provided by@angular-eslint/schematics(tseslint.configs.recommended).Because third-party linter presets like
strictTypeCheckedare opt-in, opinionated, and can conflict with other common lint rules (for example,arrow-body-style), we don't tailor the default project templates to satisfy non-default third-party lint configurations. When opting into stricter custom ESLint rulesets after generating a workspace, we recommend runningng lint --fixor updating the generated files to match your preferred ruleset.hb20007 commentedon Oct 7, 2026
@alan-agius4 Fair point; I'm providing a counterargument in case it can be reconsidered.
strictTypeCheckedis not a "third-party" preset but a nativetypescript-eslintpreset. It is not supposed to be "opinionated", since there is a separate set of rules for opinionated rules (stylisticandstylisticTypeChecked).The no-confusing-void-expression error reported is a legit type error. The
err => console.error(err)actually returns the result ofconsole.error(err), which returnsvoid. That's why it should be in{}. It does not conflict witharrow-body-stylesince that's for cases where the function is actually returning something.angular-automatic-lock-bot commentedon Nov 7, 2026
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.