watch mode 와 es6~✍🏻

2024. 9. 8. 16:41·Typescript

Typescript Watch mode!👀

tsc app.ts를 사용해서 .js 변환 후 사용하면 conflict 난다...

매번 바꿀떄마다 확인하기도 힘들고 ...

tsc app.ts -w

여러개의 파일을 comfile해야 할 떈?!

cd typescript-comfiler // 해당 파일로 이동
tsc --init // tsconfig.json 파일 생성

tsconfig.json 의 설명

typescript 를 위한 프로젝트 파일 표시기,

이 폴더에 있는 프로젝트와 모든 하위 폴더는 타입스크립트로 관리되고 있다.

tsc

=> .ts 로 생성된 파일들 전체를 .js로 변환해준다.(테스트 때 conflict 엄청 날거 같은데...)

tsconfig.json의 사용법

"exclude": ["node_modules"],
"inclued": ["analytics.ts"],
"files": ["files"]
  • exclude : uncomfile 할 file 을 지정한다.

: exclude가 없다면 node_modules 파일은 default

  • inclued : comfile 할 file 을 지정

: 없다면 전체~

  • files : 해당 파일 안에 있는 .ts 파일 전체를 comfile~

등등...

es6와 Type Script

  • 스프레드 연산자
    배열 및 객체에 저장된 데이터를 검색하는 방법!

    const hobbies = ["sports", "cooking"];
    const activeHobbies = ["Hiking"];
    
    activeHobbies.push(...hobbies);
    console.log(activeHobbies);
    
    // (3) ['Hiking', 'sports', 'cooking']

    배열은 객체이고 객체는 참조 값,

    메모르는 변경되지만, 주소는 변경되지 않는다.

    배열의 요소를 가져 올 때 사용한다.

    const hobbies = ["sports", "cooking"];
    const activeHobbies = ["Hiking"];
    
    activeHibbies.push(hobbies); // >> error 중첩 배열
    activeHibbies.push(hobbies[0], hobbies[1]); // >> error x (이렇게 가져오면 힘들어..)
    const activeHibbies = ["Hiking", ...hobbies]; // 좋은 방법!
  • rest parameters(스프레드 연산자)
    메개변수를 유동적으로 사용할 수 있다.

const add = (...numbers: number[]) => {
  return numbers.reduce((curResult, curValue) => {
    return curResult + curValue;
  }, 0);
};

const addNumbers = add(5, 3, 5, 67, 8);
console.log(addNumbers);
  • 배열 및 객체 비구조화 할당
    배열 디스트럭처링
const hobbies = ["sports", "cooking"];
const [hobbie1, hobbie2, ...remainningHibbies] = hobbies;

console.log(hobbies, hobbie1, hobbie2);
// (2) ['sports', 'cooking'] 'sports' 'cooking'

객체 비구조화 할당

const person = {
  name: "cho",
  age: 20,
};
const { name, age } = person;
console.log(name, age);
//cho 20

'Typescript' 카테고리의 다른 글

Union Type, Intersection Type, Etc...🙏(feat..optional chaining)  (3) 2024.09.11
Class...🏫  (6) 2024.09.10
처음 보는 typescript...😂  (0) 2024.09.03
'Typescript' 카테고리의 다른 글
  • Union Type, Intersection Type, Etc...🙏(feat..optional chaining)
  • Class...🏫
  • 처음 보는 typescript...😂
나미쓰
나미쓰
409....Conflict
  • 나미쓰
    나미의 기록📝
    나미쓰
  • 전체
    오늘
    어제
    • 분류 전체보기 (15)
      • 웹 접근성 (0)
      • JS (5)
      • 일상 (0)
      • Typescript (4)
      • React🦄 (4)
      • PHP (2)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
    • coding
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    javascript 생성자
    PROMISE
    axios
    API
    생성자함수
    학습블로깅
    svgr
    javascript class
    react-hook-form
    비동기 함수
    코딩공부
    watch mode
    es6
    typescript class
    optional chaining
    타입스크립트
    union type
    tsconfig
    image component
    Iterable
    php
    TypeScript
    비동기통신
    intersection type
    JavaScript
    Await
    contructor
    lalavel
    restapi
    Vite
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.4
나미쓰
watch mode 와 es6~✍🏻
상단으로

티스토리툴바