Repository navigation
[ko] Handbook - The Basics - #73
Conversation
|
Thanks for the PR! This section of the codebase is owned by Kibeom Kwon (@bumkeyy), YeonJuan (@yeonjuan), and Dan Jeong (@guyeol) - if they write a comment saying "LGTM" then it will be merged. |
Translation of Basics.mdtitle: The Basics Welcome to the first chapter of the handbook, and if you're new to TypeScript,Getting StartedWe recommend that you read one of the guide documents first. Every value in JavaScript has its own built-in behavior, which can be confirmed by running various operations. // 'message'의 프로퍼티 'toLowerCase'에 접근한 뒤
// 이를 호출합니다
message.toLowerCase();
// 'message'를 호출합니다
message();If you analyze the code above, first of all, the first line of executable code but
These questions are common when we write code in JavaScript, and we always want to make sure we don't miss out on all the little things that come with it.
const message = "Hello World!";As you may have guessed, here So what about the second line of code you saw earlier? TypeError: message is not a functionI think it would be great if we could prevent mistakes like this in advance. The JavaScript runtime is a value of type, that is, to determine what behavior and abilities the value has. Some values, for example, function fn(x) {
return x.flip();
}In the code above, an object passed as an In this respect, _type_what value is The alternative to this is Static Code is executed using a type system ago predicting the code. Static type checkingSeen If you add a little code here, save the file, and run the code again, and you'll see the error right away, you'll be able to isolate the problem quickly. But that doesn't always be the case. Ideally, you want to run the code ago It would be nice if you had a tool to spot these bugs in advance. // @errors: 2349
const message = "hello!";
message();If you run the last example above in TypeScript, you'll first see the error message before the code runs. Execution failure, not exceptionSo far, we've covered runtime errors. This is the case if the JavaScript runtime tells us something is strange. For example, according to the statement, an error occurs when you attempt to make a call for something that is not callable. const user = {
name: "Daniel",
age: 26,
};
user.location; // undefined 를 반환Ultimately, a static type system should tell you which code is considered an error within a static type system, even if it is "valid" JavaScript code that does not cause an error. // @errors: 2339
const user = {
name: "Daniel",
age: 26,
};
user.location;Although this sometimes results in the sacrifice of expressive flexibility, this is not an explicit bug, but it is aimed at catching cases that are considered a bug. For example, a typo, // @noErrors
const announcement = "Hello World!";
// 바로 보자마자 오타인지 아실 수 있나요?
announcement.toLocaleLowercase();
announcement.toLocalLowerCase();
// 아마 아래와 같이 적으려 했던 것이겠죠...
announcement.toLocaleLowerCase();Unso caller functions, // @noUnusedLocals
// @errors: 2365
function flipCoin() {
// 본래 의도는 Math.random()
return Math.random < 0.5;
}Or basic logical errors. // @errors: 2367
const value = Math.random() < 0.5 ? "a" : "b";
if (value !== "a") {
// ...
} else if (value === "b") {
// 이런, 이 블록은 실행되지 않겠군요
}Types as programming toolsTypeScript catches bugs when we make mistakes in our code. Type Checker has relevant information to help us check whether we are accessing the correct properties on a variable or other properties. In other words, TypeScript can be used to modify code, provide error messages as we type code, or provide code completion. // @noErrors
// @esModuleInterop
import express from "express";
const app = express();
app.get("/", function (req, res) {
res.sen
// ^|
});
app.listen(3000);TypeScript values programming tools, including code completion and error message capabilities.
|
YeonJuan (yeonjuan)
left a comment
There was a problem hiding this comment.
cadenzah (@cadenzah) 잘 읽히게 번역된 것 같습니다. 감사합니다 :) 띄어쓰기랑 오타 몇 개를 발견해서 제안 남겼습니다.
Co-authored-by: YeonJuan <yeonjuan93@naver.com>
YeonJuan (@yeonjuan) 검토 감사드립니다. 다음 번에는 꼭 맞춤법 검사기를 한번 돌린 뒤에 PR을 올려야겠습니다 😅 |
|
cadenzah (@cadenzah) 수정 감사합니다 :) |
|
LGTM |
|
Merging because YeonJuan (@yeonjuan) is a code-owner of all the changes - thanks! |
Uh oh!
There was an error while loading. Please reload this page.