Skip to content

Translate Unknown in Catch #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions docs/playground/ko/4-0/New TS Features/Unknown in Catch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//// { "compiler": { "ts": "4.0.2" } }

// JavaScript는 모든 값을 던질 수 있기 때문에
// TypeScript는 오류 타입 선언을 지원하지 않습니다.

try {
// ..
} catch (e) {}

// 이것은 catch 절의 `e`가 기본적으로 any 타입인 것을 의미합니다.
// 이것은 임의의 속성에 접근할 수 있는 자유를 허용합니다.
// 4.0에서는 `any`와 `unknown`을 모두 허용하도록 catch절의
// 타입 할당 제한을 완화했습니다.

// any와 동일한 동작:
try {
// ..
} catch (e) {
e.stack
}

// unknown을 사용한 명시적 동작:

try {
// ..
} catch (e: unknown) {
// 타입 시스템이 `e`가 무엇인지 알기 전에 사용할 수 없습니다.
// 자세한 내용은 다음을 참조하세요:
// example:unknown-and-never
e.stack

if (e instanceof SyntaxError) {
e.stack
}
}