- const Type Parameters (with as const) - Supporting Multiple Configuration (with Monorepo) - All enums Are Union enums (with more comfortable?), Enum Overhaul - --moduleResolution bundler - Support for export type * (with type all export Solutions) - Speed, Memory, and Package Size Optimizations (with Tools - How Optimizations) - Breaking Changes - Deprecations and Default Changes
that builds on JavaScript by adding syntax for types which can be used for type-checking. ( === Javascript + Type → TypeScript) - Type-checking can help catch lots of common mistakes, from typos to logic errors. Bringing types to JavaScript also allows us to build great tooling, since types can power features like code completions, go-to-definition, and refactorings in your favorite editor.
features, while aiming to make TypeScript smaller, simpler, and faster” - “We’ve implemented the new decorators standard, added functionality to better support ESM projects in Node and bundlers, provided new ways for library authors to control generic inference, expanded our JSDoc functionality, simplified configuration, and made many other improvements.”
선언을 통해 구체적인 타입을 지원 - [“Alice”, “Bob”, “Eve”] - string[] - [“Alice”, “Bob”, “Eve”] as const - readonly [“Alice”, “Bob”, “Eve”] - 구체적인 타입을 원할 경우어떠한 함수에 props를 넣을 때도 as const를 선언해주어야했음. - const testFunc = (props: string[]) => void; - testFunc([“Alice”, “Bob”, “Eve”]) vs testFunc([“Alice”, “Bob”, “Eve”] as const) - 다른 값 - 5.0에서는 const modifier 도입 (as const로 수정할 수 없는 값은 const modifier도 불가) - const testFunc = <const T extends readonly string[]>(props: T) => void; - testFunc([“Alice”, “Bob”, “Eve”]) vs testFunc([“Alice”, “Bob”, “Eve”] as const) - 같은 값
- 해당 경로의 tsconfig.json에서 compilerOptions를 복사해주는 기능 - 기존에는 단일 경로만 지원 → 5.0에서는 array를 지원 tsconfig.json @tsconfig/ strictest/ tsconfig.json tsconfig.base.json extends… extends…
타입을 가진 숫자 상수 집합 - 그냥 number집합 그 이상 그 이하도 아님 - 2.0 이후: enum literal types 도입 - 각 literal member에 고유한 Type 부여 + enum Type자체를 각 member Type의 합집합으로 만듦 - enum Type의 하위 집합만 참조하여 타입 범위 좁힘. - but, 각 Type들이 member의 실제 값과 일부 연관되어 있음. 해당 값을 계산 불가 (random -> number X, 7 O) - 해당 값을 정확히 계산할 수 없음. (7인지 8인지 9인지 등등 모르기에)
5.0에서 해결 - Github PR Link - enum Type에 out-of-domain literal 할당 시 이제는 Error를 띄움 (기존에는 X) - 숫자와 enum을 참조하고 있는 간접 문자열이 섞여져 있는 경우 각 member는 각 Type을 지킴 (기존에는 모든 member의 Type이 number로 잡힘)
nodenext 옵션 추가 - 목적: Node.js에서 ECMAScript module에 대한 정확한 검색 방식을 더 잘 모델링하기 위함. - but, 실제로 사용하는 다른 tool들과 부조화가 일어나는 등 제한이 존재 - import … from “./utils”; vs import … from “./utils.mjs”; - Node.js의 ECMAScript module에서는 import 시 파일 확장명이 포함되어야함. - 하지만 bundler에는 이런 제한 사항이 없기에 해당 기능이 번거로웠음. - 5.0 이후: bundler option 도입 - bundler의 작동 방식을 모델링 - vite, esbuild, swc, Webpack, Parcel 등 최신 번들러 사용 중이라면 적합함 (하이브리드 검색 전략)
- 컴파일러 내부의 객체 타입의 균일화 & 객체 무게 줄이기 - 메모리 사용량 감소 - 정보를 문자열로 바꿀 때 (에러나 유형 표시 등) 캐싱 수행 - 메모리 사용량 감소 - 클로저에서 let & const 대신 var를 사용하여 우회하여 개선 - 파싱 성능 증가 - Package Size Down - “namespaces” → “modules” migration (feat. typeformer) - Blog Link, Github PR - scope hoisting 같은 최적화할 수 있는 최신 빌드 툴들을 활용할 수 있게 됨. - 패키징 전략 재검토 & 사용하지 않는 코드 제거
Typescript Package: 최소 Node.js version이 12.20이상부터 지원 - Forbidden Implicit Coercions in Relational Operators - 문자열을 숫자로 강제 변환 할 수 있는 코드들의 경고 확장 - 5.0부터는 >, <, <=, >= 도 지원 - +연산자로 number타입 확정 시 사용 가능