씨네
공부하는 개발자 강씨네
씨네
  • 분류 전체보기 (460)
    • Web (21)
      • HTML (11)
      • CSS (10)
    • JS 관련 (49)
      • JavaScript (27)
      • JQuery (22)
    • TS 관련 (15)
      • TypeScript (15)
    • NodeJS (7)
      • NodeJS (7)
    • 따라하며 배우는 시리즈 (23)
      • NodeJS & ReactJS Basic (23)
      • NodeJS & ReactJS Movie (0)
      • NodeJS & ReactJS Youtube (0)
      • NodeJS & ReactJS ChatBot (0)
    • SPA (14)
      • React (14)
      • Vue (0)
      • Anguler (0)
    • Java 관련 (118)
      • Java (52)
      • JDBC (6)
      • JSP & Servlet (18)
      • Spring Legecy (38)
      • SpringBoot (4)
    • Python (26)
      • Python (20)
      • PyMongo (1)
      • Django (5)
    • Git (24)
      • Github (24)
    • RDB (22)
      • Oracle (21)
      • MySQL (1)
    • NoSQL (5)
      • MongoDB (5)
    • OS (4)
      • Linux (4)
    • 빅데이터 (2)
      • hadoop (2)
    • IDE (20)
      • eclipse (11)
      • VSCODE (4)
      • VisualStudio (1)
      • IntelliJ (1)
      • PyCharm (1)
      • DBeaver (2)
    • Install (3)
      • Tomcat (1)
      • Docker (1)
      • Anaconda (1)
    • 오류&에러 (28)
      • TS (2)
      • NodeJS (7)
      • SQL (8)
      • Java (1)
      • Spring (4)
      • Git (6)
      • 기타 (0)
    • 알고리즘 (67)
      • 수열 (1)
      • 백준(backjoon) (39)
      • Programmers (27)
    • 자격증 (5)
      • SQLD (5)
    • 기타 (2)
    • IT유튜브로 지식쌓기 (2)

공지사항

인기 글

최근 글

티스토리

250x250
hELLO · Designed By 정상우.
씨네

공부하는 개발자 강씨네

TS2322: Type 'string' is not assignable to type 'number'.
오류&에러/TS

TS2322: Type 'string' is not assignable to type 'number'.

2022. 7. 10. 15:22
728x90

TS2322: Type 'string' is not assignable to type 'number'.

타입스크립트를 처음 배울때 만나보는 에러일 확률이 크다.

자바스크립트만 쓰다가 타입스크립트를 쓰게 되면 이런에러를 충분히 만날가능성이 있는데 타입스크립트는 타입을 명시하지 않아도 타입을 추론한다.

let a = 5;
a = 'hello';

따라서 이런 코드는 자바스크립트에서는 사용할수 있지만 타입스크립트에서는 불가능하다.

a라는 변수에 number 타입인 5를 할당했기때문에 a에는 숫자만 들어갈수 있다.

그럼에도 문자열을 넣으려고 하기때문에 발생하는 에러인 것이다...

728x90

'오류&에러 > TS' 카테고리의 다른 글

ts(2345) Argument of type '{ hex: string; }' is not assignable to parameter of type 'Point'. Type '{ hex: string; }' is missing the following properties from type 'Point': x, yts(2345)  (0) 2022.07.24
    '오류&에러/TS' 카테고리의 다른 글
    • ts(2345) Argument of type '{ hex: string; }' is not assignable to parameter of type 'Point'. Type '{ hex: string; }' is missing the following properties from type 'Point': x, yts(2345)
    씨네
    씨네
    개발자 씨네가 공부하는 내용을 기록 겸 공유하는 블로그입니다!

    티스토리툴바