출처는 인프런입니다.
갯츠비와 타입스크립트 그래프큐엘을 통해서 블로그 만들기를 하며 배운것들을 정리합니다.
const str: string = "This is String" // Good
const num: number = "This is String" // error TS2322: Type 'string' is not assignable to type 'number'.
이렇게 타입을 지정해준다, 만약 타입이 잘못되었다면 에러가 뜬다
import React, { FunctionComponent } from 'react'
import Text from 'components/Text'
const IndexPage: FunctionComponent = function () {
return <Text text="Home" />
}
export default IndexPage
흔히 리액트에서 지정하는 컴포넌트는 FunctionComponent 타입이다
숫자형 타입만을 받을 거라는걸 알려주는 것