ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • TypeScript Til 2
    sparta TIL 2024. 6. 25. 15:06

    [ d.ts파일 ]

    // tsconfig.json 주석풂
    "allowJs": true /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */,
    "checkJs": true /* Enable error reporting in type-checked JavaScript files. */,

    "alLowJs": true → Typespript 프로젝트에 Javascript 파일 허용 여부

    "checkjs": true → Javascript 파일 타입 체크 여부

     


     

    ▼ TS에서 JS라이브러리 import 테스트해보기

    1. 테스트용으로 js파일 만들고,
    2. 명령어 실행 ▼

    npx tsc test.js --declaration --allowJs --emitDeclarationOnly --outDir types

     

    3. types폴더랑 / d.ts 파일이 생성 됨


    [ 한 입 ]

    실습 _ section1 폴더 생성 후

     

    1. Node.js 패키지 초기화 - enter-enter-enter..로 기본값으로 세팅

    2. @types/node 설치

    3. TS컴파일러 설치 - 설치후 버전확인 tsc -v

    4. ts파일을 만들고

    index.ts코드를 컴파일 - 생성된 index.js를 실행하면 잘 출력 되는것을 확인할 수 있다.

     

    'sparta TIL' 카테고리의 다른 글

    24.06.27 TIL  (1) 2024.06.27
    TypeScript 과제  (0) 2024.06.26
    TypeScript TIL 1  (0) 2024.06.25
    24.06.팀플 TIL  (0) 2024.06.18
    24.06.14 TIL  (0) 2024.06.15
Designed by Tistory.