TypeScript 3.7 정식 릴리즈

SSEN
SSEN
Nov 6 · 2 min read

드디어 등장…

TC39 적용으로 인해서 문법적 변화의 폭이 큰 마이너 업데이트다.

업데이트 관련 문서를 꼼꼼히 읽어보는게 좋다.


“Optional Chaining을 써보자~ 하악하악~” 거리면서 소스코드를 검색하는데, Null / Undefined 방어를 오질나게 해뒀더니 막상 사용할 코드가 별로 없다…;;;

if (x && x.y && x.y.z === 'match')

이런 코드를

if (x?.y?.z === 'match')

이렇게 바꾸는게 현재 내 코드들에서는 가장 큰 활용인 상황이다.

어쨌든 Null / Undefined 가능성을 없애는게 더 중요하지, 이미 발생된 Null / Undefined에 대한 핸들링은 2차적인 문제이기 때문에, Optional Chaining과 Nullish Coalescing으로 개선되는 코드가 많다는 것은 오히려 좋지 않은 신호로 해석하는게 좋을 것이다.


Babel, ESLint 관련해서 이런 문제들이 생긴다. Webpack에서 TypeScript Compile에 babel-loader를 사용하고 있거나, babel-eslint 에 얽혀있는 경우 발생될 수 있는 문제다.

Babel Config에 chainingoalescing-operator를 추가하면 해결된다.

    SSEN

    Written by

    SSEN

    https://github.com/iamssen

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade