-
Notifications
You must be signed in to change notification settings - Fork 143
1st commit: Issue #110(Intro to JS with TS) 번역 #146
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
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,69 @@ | ||
--- | ||
title: JS Projects Utilizing TypeScript | ||
layout: docs | ||
permalink: /docs/handbook/intro-to-js-ts.html | ||
oneline: How to add type checking to JavaScript files using TypeScript | ||
제목: TypeScript를 활용한 JS 프로젝트(JS Projects Utilizing TypeScript) | ||
레이아웃: 문서 | ||
고유 링크: /docs/handbook/intro-to-js-ts.html | ||
한 줄 설명: TypeScript를 사용하여 JavaScript 파일에 유형 확인을 추가하는 방법 | ||
--- | ||
|
||
The type system in TypeScript has different levels of strictness when working with a codebase: | ||
TypeScript의 타입 시스템은 코드베이스로 작업할 때 엄격함의 레벨이 다릅니다 | ||
|
||
* A type-system based only on inference with JavaScript code | ||
* Incremental typing in JavaScript [via JSDoc](/docs/handbook/jsdoc-supported-types.html) | ||
* Using `// @ts-check` in a JavaScript file | ||
* TypeScript code | ||
* TypeScript with [`strict`](/tsconfig#strict) enabled | ||
* 오직 JavaScript 코드의 추론을 기반으로 하는 타입 시스템 | ||
* [JSDoc를 통한](/docs/handbook/jsdoc-supported-types.html) JavaScript에서의 Incremental typing | ||
* JavaScript에서의 `// @ts-check` 사용 | ||
* TypeScript 코드 | ||
* [`strict`](/tsconfig#strict)이 활성화된 TypeScript | ||
|
||
Each step represents a move towards a safer type-system, but not every project needs that level of verification. | ||
각 단계는 타입시스템을 더 안전하게 만들지만, 반드시 모든 프로젝트가 이 수준에 맞는 검증을 필요로 하는 것은 아닙니다. | ||
|
||
## TypeScript with JavaScript | ||
## JavaScript를 활용한 TypeScript (TypeScript with JavaScript) | ||
|
||
This is when you use an editor which uses TypeScript to provide tooling like auto-complete, jump to symbol and refactoring tools like rename. | ||
The [homepage](/) has a list of editors which have TypeScript plugins. | ||
이는 자동 완성, 심벌로 이동 및 이름 바꾸기와 같은 리팩토링 툴을 제공하기 위해서 TypeScript를 사용하는 에디터를 사용할 때 유용합니다. | ||
[홈페이지](/)에는 TypeScript 플러그인들이 있는 편집자 목록이 있습니다. | ||
|
||
## Providing Type Hints in JS via JSDoc | ||
## JSDoc을 통하여 JS에 타입 힌트 제공하기 (Providing Type Hints in JS via JSDoc) | ||
|
||
In a `.js` file, types can often be inferred. When types can't be inferred, they can be specified using JSDoc syntax. | ||
`.js` 파일에서는, 종종 타입들을 유추할 수 있습니다. 타입들을 유추할 수 없는 경우, JSDoc 구문을 사용하여 구체적으로 알릴 수 있습니다. | ||
|
||
JSDoc annotations come before a declaration will be used to set the type of that declaration. For example: | ||
JSDoc 주석은 선언 앞에 위치하며 특정 선언의 타입을 설정하는 데 사용됩니다. 예를 들어: | ||
|
||
```js twoslash | ||
```js | ||
/** @type {number} */ | ||
var x; | ||
|
||
x = 0; // OK | ||
x = false; // OK?! | ||
x = 0; // 성공 | ||
x = false; // 성공?! | ||
``` | ||
|
||
You can find the full list of supported JSDoc patterns [in JSDoc Supported Types](/docs/handbook/jsdoc-supported-types.html). | ||
지원되는 JSDoc 패턴의 전체 목록은 [JSDoc가 지원하는 타입에서](/docs/handbook/jsdoc-supported-types.html) 찾을 수 있습니다. | ||
|
||
## `@ts-check` | ||
|
||
The last line of the previous code sample would raise an error in TypeScript, but it doesn't by default in a JS project. | ||
To enable errors in your JavaScript files add: `// @ts-check` to the first line in your `.js` files to have TypeScript raise it as an error. | ||
이전 코드 예시의 마지막 줄은 TypeScript에서 오류를 발생시키지만, JS 프로젝트에서는 기본적으로 오류를 발생시키지 않습니다. | ||
JavaScript 파일에서 오류를 실행하려면 다음을 추가해야 합니다: `.js` 파일의 첫 번째 줄에 `// @ts-check`를 추가하여 TypeScript가 이를 오류로 올리도록 해야 합니다. | ||
|
||
```js twoslash | ||
// @ts-check | ||
// @errors: 2322 | ||
/** @type {number} */ | ||
var x; | ||
|
||
x = 0; // OK | ||
x = false; // Not OK | ||
x = 0; // 성공 | ||
x = false; // 성공 아님 | ||
``` | ||
|
||
If you have a lot of JavaScript files you want to add errors to then you can switch to using a [`jsconfig.json`](/docs/handbook/tsconfig-json.html). | ||
You can skip checking some files by adding a `// @ts-nocheck` comment to files. | ||
만일 오류를 추가하려는 JavaScript 파일이 많은 경우, [`jsconfig.json`](/docs/handbook/tsconfig-json.html) 역시 사용할 수 있습니다. | ||
파일에 `// @ts-nocheck` 코멘트를 추가하면 일부 파일 확인을 건너뛸 수 있습니다. | ||
|
||
TypeScript may offer you errors which you disagree with, in those cases you can ignore errors on specific lines by adding `// @ts-ignore` or `// @ts-expect-error` on the preceding line. | ||
TypeScript는 우리가 동의하지 않는 오류들을 제공할 수도 있는데, 이 경우 특정 줄 맨앞에 `// @ts-ignore` 또는 `// @ts-expect-error`를 추가하여 그 줄의 오류를 무시할 수 있습니다. | ||
|
||
```js twoslash | ||
guyeol marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// @ts-check | ||
/** @type {number} */ | ||
var x; | ||
|
||
x = 0; // OK | ||
x = 0; // 성공 | ||
// @ts-expect-error | ||
x = false; // Not OK | ||
x = false; // 성공 아님 | ||
``` | ||
|
||
To learn more about how JavaScript is interpreted by TypeScript read [How TS Type Checks JS](/docs/handbook/type-checking-javascript-files.html) | ||
JavaScript를 TypeScript로 해석하는 방법에 대한 자세한 내용은 [TS Type이 JS를 체크하는 방법](/docs/handbook/type-checking-javascript-files.html)을 참고하시기 바랍니다. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.