본문 바로가기
반응형

프론트엔드/타입스크립트4

왜 <T>를 as T로 바꾸라고 하는걸까? https://typescript-eslint.io/rules/consistent-type-assertions/ consistent-type-assertions | typescript-eslint Enforce consistent usage of type assertions. typescript-eslint.io 타입 변경에 사용한 부분에서 경고 메시지가 뜬다. 대신에 as T를 쓰라는 가이드가 있어서 보니.. 하나로 맞추라는 의미도 있고 JSX 문법이랑 헷갈리기 때문이라고 한다. 2023. 5. 31.
in 키워드 보호되어 있는 글 입니다. 2022. 12. 10.
Parsing error: The keyword 'enum' is reserved 공통으로 쓰는 패키지들은 별도의 git 리포지토리에서 관리되며 사용할떄 git module 설정으로 불러와서 사용중이었는데 패키지 안에 선언된 enum 클래스를 사용하려고만 하면 터져버렸다.... Parsing error: The keyword 'enum' is reserved I am writing TypeScript with React. The project was generated with CRA. and I used react-app config for the .eslintrc.json. However I decided to use eslint-config-airbnb so I added it and changed my . stackoverflow.com parser를 바꿔주면 된다고 하여... .. 2022. 12. 10.
타입스크립트 객체에 속성 추가하기 타입스크립트에서는 객체에 속성이 그냥 추가가 되지 않는다. 왜냐 타입이 존재하기 때문 이 글에서는 Record라는 유틸리티 클래스를 사용해서 마음대로 추가도 가능하면서 타입 제한도 어느정도 가능한 사용방법을 보여준다. https://bobbyhadz.com/blog/typescript-add-property-to-object How to Add a property to an Object in TypeScript | bobbyhadz To add a property to an object in TypeScript, set the property as optional on the interface you assign to the object using a question mark. You can then a.. 2022. 11. 28.
반응형