Refactoring Legacy Code: 04 Typescript Migration
Автор: Code Made Simple
Загружено: 2023-11-19
Просмотров: 119
Описание:
In episode 03 we moved to ES6 as a step towards moving to Typescript. In this video, we are taking the first step towards moving to Typescript where we configure the builds to be done through Typescript while still supporting Javascript. In the next episode, we will convert all existing Javascript file.
Having a gradual migration path is key so you can avoid long living feature branches and conflicts.
Repository: https://github.com/kobbikobb/console-...
#softwaredeveloper #nodejs
The steps in this video:
```
Uninstall Babel
npm uninstall @babel/cli @babel/core @babel/preset-env babel-jest
Delete redundant files
.babelrc
Install Typescript related packages
npm install --save-dev typescript ts-node ts-jest @typescript-eslint/eslint-plugin @typescript-eslint/parser
Adjust build script
"build": "tsc",
"start": "npm run build && ts-node dist/index.js"
Create tsconfig.json (npx tsc --init)
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"rootDir": "./src",
"outDir": "./dist",
"strict": true,
"allowJs": true,
"esModuleInterop": true,
"skipLibCheck": true
},
"include": [
"src/**/*.ts",
"src/**/*.js",
],
}
Adjust jest.config.json
{
"roots": ["src"],
"transform": {
"^.+\\.[tj]s?$": ["ts-jest"]
},
"preset": "ts-jest",
"testEnvironment": "node"
}
Update ESLint
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
```
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: