https://github.com/uzoolove/FESP02-typescript.git 입력npm i typescript -g
function hello(name: string): string {
return 'Hello ' + name;
}
console.log(hello('TypeScript'));
cd workspace/ch01
tsc 01.ts
node 01.js
tsc --init
tsc --watch
npx serve .
npm init -y
npx eslint@latest --init
또는
npm init @eslint/config@latest
Need to install the following packages: @eslint/create-config@1.1.5 Ok to proceed? (y)
- y
? How would you like to use ESLint?
- To check syntax and find problems
? What type of modules does your project use?
- JavaScript modules (import/export)
? Which framework does your project use?
- None of these
? Does your project use TypeScript?
- Yes
? Where does your code run?
- browser
The config that you have selected requires the following dependencies:
eslint@9.x, globals, @eslint/js, typescript-eslint
? Would you like to install them now?
- Yes
? Which package manager do you want to use?
- npm
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
export default [
{ files: ["**/*.{js,mjs,cjs,ts}"] },
{ languageOptions: { globals: globals.browser } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
];
export default [
......
{
"rules": {
"no-var": "off", // var 키워드 사용 가능
"prefer-const": "warn", // 변수가 재할당 되지 않는다면 let 대신 const 사용
"no-cond-assign": "warn", // 조건문에서 변수값 할당식 사용
"no-redeclare": "warn", // 변수 중복 선언
"@typescript-eslint/no-unused-vars": "warn", // 사용하지 않는 변수
"@typescript-eslint/explicit-function-return-type": "off", // 함수의 리턴타입을 명시적으로 지정하지 않아도 됨
"@typescript-eslint/no-explicit-any": "warn", // any 타입 사용
}
}
]
npx eslint .
npx eslint ./ch01
npx eslint ./ch01/01.ts
npm i -D eslint
# 또는
npm i -g eslint