Skip to content

Commit c43cc3b

Browse files
dhyoo99guyeoldvlprsh
authored
1st commit: Issue #110(Intro to JS with TS) ๋ฒˆ์—ญ (#146)
* translated issue #110 * ๋ฆฐํŠธ ํ…Œ์ŠคํŠธ ์ˆ˜ํ–‰ * Update pages/intro-to-js-with-ts.md Co-authored-by: Seohee Park <[email protected]> * Update pages/intro-to-js-with-ts.md Co-authored-by: Seohee Park <[email protected]> Co-authored-by: GuyeolJeong <[email protected]> Co-authored-by: Seohee Park <[email protected]>
1 parent 1bab57c commit c43cc3b

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

Diff for: โ€Žpages/intro-to-js-with-ts.md

+33-33
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,69 @@
11
---
2-
title: JS Projects Utilizing TypeScript
3-
layout: docs
4-
permalink: /docs/handbook/intro-to-js-ts.html
5-
oneline: How to add type checking to JavaScript files using TypeScript
2+
์ œ๋ชฉ: TypeScript๋ฅผ ํ™œ์šฉํ•œ JS ํ”„๋กœ์ ํŠธ(JS Projects Utilizing TypeScript)
3+
๋ ˆ์ด์•„์›ƒ: ๋ฌธ์„œ
4+
๊ณ ์œ  ๋งํฌ: /docs/handbook/intro-to-js-ts.html
5+
ํ•œ ์ค„ ์„ค๋ช…: TypeScript๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ JavaScript ํŒŒ์ผ์— ์œ ํ˜• ํ™•์ธ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ•
66
---
77

8-
The type system in TypeScript has different levels of strictness when working with a codebase:
8+
TypeScript์˜ ํƒ€์ž… ์‹œ์Šคํ…œ์€ ์ฝ”๋“œ๋ฒ ์ด์Šค๋กœ ์ž‘์—…ํ•  ๋•Œ ์—„๊ฒฉํ•จ์˜ ๋ ˆ๋ฒจ์ด ๋‹ค๋ฆ…๋‹ˆ๋‹ค
99

10-
* A type-system based only on inference with JavaScript code
11-
* Incremental typing in JavaScript [via JSDoc](/docs/handbook/jsdoc-supported-types.html)
12-
* Using `// @ts-check` in a JavaScript file
13-
* TypeScript code
14-
* TypeScript with [`strict`](/tsconfig#strict) enabled
10+
* ์˜ค์ง JavaScript ์ฝ”๋“œ์˜ ์ถ”๋ก ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•˜๋Š” ํƒ€์ž… ์‹œ์Šคํ…œ
11+
* [JSDoc๋ฅผ ํ†ตํ•œ](/docs/handbook/jsdoc-supported-types.html) JavaScript์—์„œ์˜ Incremental typing
12+
* JavaScript์—์„œ์˜ `// @ts-check` ์‚ฌ์šฉ
13+
* TypeScript ์ฝ”๋“œ
14+
* [`strict`](/tsconfig#strict)์ด ํ™œ์„ฑํ™”๋œ TypeScript
1515

16-
Each step represents a move towards a safer type-system, but not every project needs that level of verification.
16+
๊ฐ ๋‹จ๊ณ„๋Š” ํƒ€์ž…์‹œ์Šคํ…œ์„ ๋” ์•ˆ์ „ํ•˜๊ฒŒ ๋งŒ๋“ค์ง€๋งŒ, ๋ฐ˜๋“œ์‹œ ๋ชจ๋“  ํ”„๋กœ์ ํŠธ๊ฐ€ ์ด ์ˆ˜์ค€์— ๋งž๋Š” ๊ฒ€์ฆ์„ ํ•„์š”๋กœ ํ•˜๋Š” ๊ฒƒ์€ ์•„๋‹™๋‹ˆ๋‹ค.
1717

18-
## TypeScript with JavaScript
18+
## JavaScript๋ฅผ ํ™œ์šฉํ•œ TypeScript (TypeScript with JavaScript)
1919

20-
This is when you use an editor which uses TypeScript to provide tooling like auto-complete, jump to symbol and refactoring tools like rename.
21-
The [homepage](/) has a list of editors which have TypeScript plugins.
20+
์ด๋Š” ์ž๋™ ์™„์„ฑ, ์‹ฌ๋ฒŒ๋กœ ์ด๋™ ๋ฐ ์ด๋ฆ„ ๋ฐ”๊พธ๊ธฐ์™€ ๊ฐ™์€ ๋ฆฌํŒฉํ† ๋ง ํˆด์„ ์ œ๊ณตํ•˜๊ธฐ ์œ„ํ•ด์„œ TypeScript๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์—๋””ํ„ฐ๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค.
21+
[ํ™ˆํŽ˜์ด์ง€](/)์—๋Š” TypeScript ํ”Œ๋Ÿฌ๊ทธ์ธ๋“ค์ด ์žˆ๋Š” ํŽธ์ง‘์ž ๋ชฉ๋ก์ด ์žˆ์Šต๋‹ˆ๋‹ค.
2222

23-
## Providing Type Hints in JS via JSDoc
23+
## JSDoc์„ ํ†ตํ•˜์—ฌ JS์— ํƒ€์ž… ํžŒํŠธ ์ œ๊ณตํ•˜๊ธฐ (Providing Type Hints in JS via JSDoc)
2424

25-
In a `.js` file, types can often be inferred. When types can't be inferred, they can be specified using JSDoc syntax.
25+
`.js` ํŒŒ์ผ์—์„œ๋Š”, ์ข…์ข… ํƒ€์ž…๋“ค์„ ์œ ์ถ”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํƒ€์ž…๋“ค์„ ์œ ์ถ”ํ•  ์ˆ˜ ์—†๋Š” ๊ฒฝ์šฐ, JSDoc ๊ตฌ๋ฌธ์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ตฌ์ฒด์ ์œผ๋กœ ์•Œ๋ฆด ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
2626

27-
JSDoc annotations come before a declaration will be used to set the type of that declaration. For example:
27+
JSDoc ์ฃผ์„์€ ์„ ์–ธ ์•ž์— ์œ„์น˜ํ•˜๋ฉฐ ํŠน์ • ์„ ์–ธ์˜ ํƒ€์ž…์„ ์„ค์ •ํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด:
2828

29-
```js twoslash
29+
```js
3030
/** @type {number} */
3131
var x;
3232

33-
x = 0; // OK
34-
x = false; // OK?!
33+
x = 0; // ์„ฑ๊ณต
34+
x = false; // ์„ฑ๊ณต?!
3535
```
3636

37-
You can find the full list of supported JSDoc patterns [in JSDoc Supported Types](/docs/handbook/jsdoc-supported-types.html).
37+
์ง€์›๋˜๋Š” JSDoc ํŒจํ„ด์˜ ์ „์ฒด ๋ชฉ๋ก์€ [JSDoc๊ฐ€ ์ง€์›ํ•˜๋Š” ํƒ€์ž…์—์„œ](/docs/handbook/jsdoc-supported-types.html) ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
3838

3939
## `@ts-check`
4040

41-
The last line of the previous code sample would raise an error in TypeScript, but it doesn't by default in a JS project.
42-
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.
41+
์ด์ „ ์ฝ”๋“œ ์˜ˆ์‹œ์˜ ๋งˆ์ง€๋ง‰ ์ค„์€ TypeScript์—์„œ ์˜ค๋ฅ˜๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค์ง€๋งŒ, JS ํ”„๋กœ์ ํŠธ์—์„œ๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ์˜ค๋ฅ˜๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
42+
JavaScript ํŒŒ์ผ์—์„œ ์˜ค๋ฅ˜๋ฅผ ์‹คํ–‰ํ•˜๋ ค๋ฉด ๋‹ค์Œ์„ ์ถ”๊ฐ€ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค: `.js` ํŒŒ์ผ์˜ ์ฒซ ๋ฒˆ์งธ ์ค„์— `// @ts-check`๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ TypeScript๊ฐ€ ์ด๋ฅผ ์˜ค๋ฅ˜๋กœ ์˜ฌ๋ฆฌ๋„๋ก ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
4343

44-
```js twoslash
44+
```js
4545
// @ts-check
4646
// @errors: 2322
4747
/** @type {number} */
4848
var x;
4949

50-
x = 0; // OK
51-
x = false; // Not OK
50+
x = 0; // ์„ฑ๊ณต
51+
x = false; // ์„ฑ๊ณต ์•„๋‹˜
5252
```
5353

54-
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).
55-
You can skip checking some files by adding a `// @ts-nocheck` comment to files.
54+
๋งŒ์ผ ์˜ค๋ฅ˜๋ฅผ ์ถ”๊ฐ€ํ•˜๋ ค๋Š” JavaScript ํŒŒ์ผ์ด ๋งŽ์€ ๊ฒฝ์šฐ, [`jsconfig.json`](/docs/handbook/tsconfig-json.html) ์—ญ์‹œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
55+
ํŒŒ์ผ์— `// @ts-nocheck` ์ฝ”๋ฉ˜ํŠธ๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด ์ผ๋ถ€ ํŒŒ์ผ ํ™•์ธ์„ ๊ฑด๋„ˆ๋›ธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
5656

57-
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.
57+
TypeScript๋Š” ์šฐ๋ฆฌ๊ฐ€ ๋™์˜ํ•˜์ง€ ์•Š๋Š” ์˜ค๋ฅ˜๋“ค์„ ์ œ๊ณตํ•  ์ˆ˜๋„ ์žˆ๋Š”๋ฐ, ์ด ๊ฒฝ์šฐ ํŠน์ • ์ค„ ๋งจ์•ž์— `// @ts-ignore` ๋˜๋Š” `// @ts-expect-error`๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ๊ทธ ์ค„์˜ ์˜ค๋ฅ˜๋ฅผ ๋ฌด์‹œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
5858

59-
```js twoslash
59+
```js
6060
// @ts-check
6161
/** @type {number} */
6262
var x;
6363

64-
x = 0; // OK
64+
x = 0; // ์„ฑ๊ณต
6565
// @ts-expect-error
66-
x = false; // Not OK
66+
x = false; // ์„ฑ๊ณต ์•„๋‹˜
6767
```
6868

69-
To learn more about how JavaScript is interpreted by TypeScript read [How TS Type Checks JS](/docs/handbook/type-checking-javascript-files.html)
69+
JavaScript๋ฅผ TypeScript๋กœ ํ•ด์„ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ [TS Type์ด JS๋ฅผ ์ฒดํฌํ•˜๋Š” ๋ฐฉ๋ฒ•](/docs/handbook/type-checking-javascript-files.html)์„ ์ฐธ๊ณ ํ•˜์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.

0 commit comments

Comments
ย (0)