# index signature

13개의 포스트

TypeScript | index signature (인덱스 시그니처)

사프로 열코 중에, 객체의 특정 value를 가져와야 해서 obj\[key]식으로 접근했는데 TypeError가 발생! 🚨해당 에러를 구글링 하다 Index Signature를 알게되어 공부하게 되었다.기존 JavaScript에서 객체에 접근을해보자.특정 value에

2023년 8월 31일
·
0개의 댓글
·
post-thumbnail

[TypeScript] 객체(key:value) 생성하기

TypeScript에서 객체 생성하기, 변수로 객체의 값에 접근하기

2023년 8월 8일
·
0개의 댓글
·

index signatures - object 타입 지정

object 타입 지정할 때 index signatures 를 사용하면 편리합니당🙄

2023년 8월 2일
·
0개의 댓글
·
post-thumbnail

Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ week: string; month: string; }'. No index signature with a parameter of type 'string' was found on type '{ week: string; month: string; }'.

문제상황 이와 같은 코드를 작성했을 때, return title[type]부분에서 에러가 발생함 해결방법 TypeScript에서는 객체에 인덱싱을 할 때, 해당 객체의 타입에 인덱스 시그니처가 없기 때문에 오류가 발생합니다.

2023년 7월 24일
·
0개의 댓글
·

index signature에 대한 interface와 type alias의 차이점

interface로 선언된 타입의 경우 implicit index signature 가 지원되지 않는다고 합니다.type alias의 경우는 암묵적 index signature 가 적용되어 index signature를 명시적으로 선언하지 않아도 타입 체크를 통과하는

2023년 5월 17일
·
0개의 댓글
·
post-thumbnail

[TypeScript] Index Signature란?

프로젝트 진행 중, 코드를 리팩토링하면서 아래와 같이 map으로 정의하여 tailwind 식의 css를 부여하려했다. 하지만 이 과정에서 오류가 발생했고, TypeScript는 기본적으로 객체의 프로퍼티를 읽을 때, string 타입의 key 사용을 허용하지 않는다것을

2023년 2월 11일
·
0개의 댓글
·
post-thumbnail

ComAround_인덱스 시그니처(Index Signature) / 타입스크립트

인덱스 시그니처 방식의 타입지정을 통해 한번만 사용하는 객체의 타입지정을 간편하게 처리했다.인덱스 시그니처는 key와 value의 타입을 정확히 명시해야 하는 경우 사용할 수 있다.key : value 형식으로 사용한다.Ex. { \[Key: T]: U }\[key:

2023년 1월 28일
·
0개의 댓글
·

TypeScript 배우기2

TypeScript 배우기2

2022년 7월 27일
·
0개의 댓글
·

타입스크립트 정리

타입스크립트로 계산기를 만들어보며, 배웠던 점을 정리하고자 한다.

2022년 7월 15일
·
0개의 댓글
·

Typescript - TS7053

Typescript 는 string 타입의 key 를 허용하지 않는다.String Literal 또는 number 타입만 허용된다.https://bobbyhadz.com/blog/typescript-add-property-to-objecthttps:/

2022년 6월 30일
·
0개의 댓글
·

[TS] TypeScript와 Object

JavaScript object 모듈을 TypeScript에서 다루기

2022년 1월 27일
·
0개의 댓글
·
post-thumbnail

TIL 71 | Index signature

Typescript - Index signature

2021년 10월 23일
·
0개의 댓글
·