아직 정해지지 않은 key와 value로 이루어진 객체의 type은 아래와 같이 작성하였다.
interface useFormInterface {
[key: string]: string | number;
}
export function useForm(initialValues: useFormInterface) {
* Type Alias + Index Signature + Union Type
type alias의 경우 저렇게 type을 사용하여 따로 만들어 사용하는 것, index signature는 [key: string] 같이 어떤 key값이 들어올지 모르겠으나 전부 통틀어 string 타입으로 지정하는 방식을 말한다.
그리고 union type은 string | number처럼 or인 |로 여러 타입을 같이 선언하는 것을 의미한다.
https://mine-it-record.tistory.com/581
[TypeScript] 객체타입 - object, array, tupple
타입 스크립트에서 사용하는 타입 중에 object, array, tupple 객체 타입에 대해 알아보자. Object object타입은 javascript에서라면 정말 흔하게 자주 사용하던 타입이나, typescript에서 사용하려면 조금 까다
mine-it-record.tistory.com
'Type Script > Type 적용' 카테고리의 다른 글
[TS] 객체로 이루어진 배열 type(feat.props) (1) | 2023.03.08 |
---|---|
[TS]TypeScript에서 useRef type 사용 방법 (0) | 2023.03.08 |
[TS] change, submit e매개변수 type, onChange type (feat.Type보는 방법) (0) | 2023.03.07 |
[TS] children Type (0) | 2023.03.07 |
[TS] ref type 오류해결 forwardedref<unknown>...(+never형식에 focus속성이 없다) (0) | 2023.03.07 |