# TypeScript 5.2의 새로운 키워드 - using

> Clean Markdown view of GeekNews topic #9433. Use the original source for factual precision when an external source URL is present.

## Metadata

- GeekNews HTML: [https://news.hada.io/topic?id=9433](https://news.hada.io/topic?id=9433)
- GeekNews Markdown: [https://news.hada.io/topic/9433.md](https://news.hada.io/topic/9433.md)
- Type: news
- Author: [kuroneko](https://news.hada.io/@kuroneko)
- Published: 2023-06-20T09:47:16+09:00
- Updated: 2023-06-20T09:47:16+09:00
- Original source: [totaltypescript.com](https://www.totaltypescript.com/typescript-5-2-new-keyword-using)
- Points: 12
- Comments: 1

## Topic Body

- TypeScript 5.2에서 범위를 벗어날 때 명시적으로 개체를 처분할 수 있는 새로운 키워드인 `using` 추가.  
- C# 등에 이미 존재하던 using과 유사한 기능.  
  - 특정 함수가 객체를 반환할 때, `Symbol.dispose` 기호를 사용해 함수를 할당.  
  - `using`을 통해 해당 함수를 호출.  
  - 이후 범위를 벗어날 때, `Symbol.dispose` 함수가 호출됨.  
- 최근 3단계에 도달한 [TC39의 명시적 자원 관리 제안](https://github.com/tc39/proposal-explicit-resource-management)에 기반함.  
- `Symbol.asyncDispose`를 통해 비동기 함수를 할당하고, `await using`을 사용해 비동기적으로 개체를 처리할 수 있음.  
- DB 연결, 파일 핸들러 등 다양한 상황에 활용 가능.

## Comments



### Comment 16626

- Author: kuroneko
- Created: 2023-06-20T09:51:59+09:00
- Points: 1

이 기능은 사실 타입스크립트 기능은 아니고, ECMAScript에 제안된 기능에 기반한 일종의 폴리필 느낌입니다.  
TC39의 제안에 의해 자바스크립트에서도 구현될 예정이라고 하네요.  
  
저는 C# 할 때 `using`이 좀 편했던 기억이 있어서 환영이긴 한데,  
결국 `try ... finally`랑 똑같은 거 아니냐 란 말들도 좀 있네요.
