NestJS v10 -> v11
To upgrade Nest from v10 to v11, please refer to the previous document for the basic part, related to updating Node and Nest, and installing/executing ncu. In this case, update everything.
The steps specific to this version update are as follows:
Add the following dependencies:
yarn add -D @eslint/eslintrc @eslint/js @swc/cli @swc/core globals typescript-eslintRemove the following ones:
yarn remove @typescript-eslint/eslint-plugin @typescript-eslint/parserIn tsconfig.json, enable the following options:
strictNullChecksforceConsistentCasingInFileNames
The ESLint file is now eslint.config.mjs, and has the following base template:
// @ts-check
import eslint from '@eslint/js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import globals from 'globals';
import tseslint from 'typescript-eslint';
export default tseslint.config(
{
ignores: ['eslint.config.mjs'],
},
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
eslintPluginPrettierRecommended,
{
languageOptions: {
globals: {
...globals.node,
...globals.jest,
},
ecmaVersion: 5,
sourceType: 'module',
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn'
},
},
);In the e2e test file, use
Appas type parameter forappand as type forserverIn the main file, prefix the
bootstrap()call with void to explicitly not await it
With this, the project is updated. However, I'll make some more changes related to type safety strictness, as to make it more flexible:
In tsconfig.json, disable
strictNullChecksIn esling.config.mjs, in
rules, disable the following options (mainly related to any handling):
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'no-case-declarations': 'off',Commit - Upgrading from NestJS v10 to v11
Last updated