λ°˜μ‘ν˜•

typescript error 3

[TypeScript] Could not find a declaration file for module 였λ₯˜ 원인 및 ν•΄κ²° 방법

Intro μ•ˆλ…•ν•˜μ„Έμš”. νƒ€μž…μŠ€ν¬λ¦½νŠΈ μ‚¬μš© 쀑 λ‹€μŒμ˜ μ—λŸ¬κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€. Could not find a declaration file for module Why? 이 였λ₯˜ λ©”μ‹œμ§€λŠ” μ—°κ²°λœ declaration file 이 μ—†λŠ” νƒ€μž…μŠ€ν¬λ¦½νŠΈ μ½”λ“œ μ•ˆμ— λͺ¨λ“ˆμ΄λ‚˜ 라이브러리λ₯Ό μ‚¬μš©ν•  λ•Œ λ°œμƒν•˜λŠ” μ „ν˜•μ μΈ 였λ₯˜μž…λ‹ˆλ‹€. declaration file(.d.ts)λŠ” λͺ¨λ“ˆμ΄λ‚˜ 라이브러리의 types, functions 및 기타 속성을 μ„€λͺ…ν•˜κ³  νƒ€μž…μŠ€ν¬λ¦½νŠΈκ°€ μ½”λ“œμ—μ„œ 이듀을 μ‚¬μš©ν•˜λŠ” 방법을 이해할 수 μžˆλ„λ‘ ν•©λ‹ˆλ‹€. λ”°λΌμ„œ μ„€μΉ˜λœ νŠΉμ • λͺ¨λ“ˆ/λΌμ΄λΈŒλŸ¬λ¦¬μ— λŒ€ν•œ type μ •μ˜κ°€ μ—†μ–΄ νƒ€μž…μŠ€ν¬λ¦½νŠΈμ—μ„œ 이해할 수 μ—†μœΌλ―€λ‘œ λ‹€μŒμ˜ 였λ₯˜κ°€ λ°œμƒν•œ κ²ƒμž…λ‹ˆλ‹€. How to solve the problem 이 였λ₯˜λ₯Ό ν•΄κ²°ν•˜κΈ° μœ„ν•΄μ„œλŠ”..

[TypeScript] cannot read properties of undefined μ—λŸ¬ 원인 및 해결방법

Intro μ•ˆλ…•ν•˜μ„Έμš”. νƒ€μž…μŠ€ν¬λ¦½νŠΈλ₯Ό μ‚¬μš©ν•˜λ˜ 도쀑 μ•„λž˜μ™€ 같은 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€. Why? ν•΄λ‹Ή properties의 값을 읽을 수 μ—†κΈ° λ•Œλ¬Έμ— λ°œμƒν•˜λŠ” 였λ₯˜μž…λ‹ˆλ‹€. How to solve the problem ν•΄λ‹Ή μ—λŸ¬λ₯Ό ν•΄κ²°ν•˜λŠ” 방법은 μ—¬λŸ¬κ°€μ§€μΈλ°μš”, μ €λŠ” κ·Έ μ€‘μ—μ„œλ„ Optional Chaining μ—°μ‚°μž (λ¬ΌμŒν‘œ μ—°μ‚°μž)λ₯Ό μ‚¬μš©ν•˜μ—¬ ν•΄λ‹Ή 였λ₯˜λ₯Ό ν•΄κ²°ν•  수 μžˆμ—ˆμŠ΅λ‹ˆλ‹€. μ½”λ“œ μ‚¬μš© μ˜ˆμ œλŠ” μ•„λž˜μ™€ κ°™μŠ΅λ‹ˆλ‹€. return ( {item?.name} ) μ΄λ ‡κ²Œ Optional Chaining μ—°μ‚°μž (λ¬ΌμŒν‘œ μ—°μ‚°μž)λ₯Ό μ‚¬μš©ν•  경우 μœ νš¨ν•œ 값이 없을 λ•ŒλŠ” undefinedλ₯Ό λ°˜ν™˜ν•˜κ³ , 값이 μžˆμ„ λ•ŒλŠ” Optional Chaining μ—°μ‚°μž 이후 λ‚΄μš©μ„ μ‹€ν–‰ν•©λ‹ˆλ‹€. λ”°λΌμ„œ ν•΄λ‹Ή 였λ₯˜λ₯Ό 방지할 수 μžˆμŠ΅λ‹ˆλ‹€.

[TypeScript] The left-hand side of an assignment expression may not be an optional property access 였λ₯˜ 원인 및 ν•΄κ²° 방법

Intro μ•ˆλ…•ν•˜μ„Έμš”. TypeScript νƒ€μž…μŠ€ν¬λ¦½νŠΈμ—μ„œ refλ₯Ό μ‚¬μš©ν•˜μ—¬ scrollTop μœ„μΉ˜λ₯Ό λ³€κ²½ν•˜λ˜ 도쀑 μ•„λž˜μ™€ 같은 μ—λŸ¬κ°€ λ°œμƒν•˜μ˜€μŠ΅λ‹ˆλ‹€ someRef?.current?.scrollTop = 0; TS2779: The left-hand side of an assignment expression may not be an optional property access Why? μŠ€νŽ™ μƒμ—μ„œ μ˜΅μ…”λ„ 체이닝과 할당을 같이 μ‚¬μš©ν•  수 μ—†λ‹€κ³  ν•©λ‹ˆλ‹€. The following is not supported, although it has some use cases; see Issue #18 for discussion: optional property assignment: a?.b = c How to solv..

λ°˜μ‘ν˜•