Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 072f2a0

Browse files
guyeolbumkeyy
andauthored
library structures ~ 끝 (ref #144) (#214)
* library structures ~ 끝 * Update pages/declaration-files/library-structures.md Co-Authored-By: Kibeom Kwon <kgbum2222@gmail.com> * Update pages/declaration-files/library-structures.md Co-Authored-By: Kibeom Kwon <kgbum2222@gmail.com> Co-authored-by: Kibeom Kwon <kgbum2222@gmail.com>
1 parent 5ea7425 commit 072f2a0

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

pages/declaration-files/library-structures.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -318,57 +318,57 @@ import * as someLib from 'someLib';
318318

319319
UMD 라이브러리에 대한 의존성 선언에 `/// <reference` 디렉티브를 사용하지 *마세요*!
320320

321-
# Footnotes
321+
# 각주 (Footnotes)
322322

323-
## Preventing Name Conflicts
323+
## 이름 충돌 방지하기 (Preventing Name Conflicts)
324324

325-
Note that it's possible to define many types in the global scope when writing a global declaration file.
326-
We strongly discourage this as it leads to possible unresolvable name conflicts when many declaration files are in a project.
325+
전역 선언 파일을 작성할 때, 전역 스코프에 많은 타입을 정의할 수 있다는 점을 유의하세요.
326+
많은 선언 파일이 프로젝트 내에 있을 때, 해결할 수 없는 이름 충돌이 발생할 수 있으므로 이를 사용하지 않는 것이 좋습니다.
327327

328-
A simple rule to follow is to only declare types *namespaced* by whatever global variable the library defines.
329-
For example, if the library defines the global value 'cats', you should write
328+
따라야 하는 간단한 규칙은 라이브러리가 정의한 전역 변수가 무엇이든 타입을 *네임스페이스*로 정의하는 것입니다.
329+
예를 들어, 만약 라이브러리가 전역 값 'cats'를 정의하면, 다음과 같이 작성하고
330330

331331
```ts
332332
declare namespace cats {
333333
interface KittySettings { }
334334
}
335335
```
336336
337-
But *not*
337+
이렇게 하지는 *마세요*
338338
339339
```ts
340-
// at top-level
340+
// 최상위-레벨에서
341341
interface CatsKittySettings { }
342342
```
343343
344-
This guidance also ensures that the library can be transitioned to UMD without breaking declaration file users.
344+
이 가이드는 선언 파일 사용자가 중단하지 않고 라이브러리를 UMD로 전환할 수 있도록 합니다.
345345
346-
## The Impact of ES6 on Module Plugins
346+
## ES6가 모듈 플러그인에 미치는 영향 (The Impact of ES6 on Module Plugins)
347347
348-
Some plugins add or modify top-level exports on existing modules.
349-
While this is legal in CommonJS and other loaders, ES6 modules are considered immutable and this pattern will not be possible.
350-
Because TypeScript is loader-agnostic, there is no compile-time enforcement of this policy, but developers intending to transition to an ES6 module loader should be aware of this.
348+
어떤 플러그인은 기존 모듈에 최상위 export를 추가하거나 수정합니다.
349+
CommonJS와 다른 로더에서는 허용되지만, ES6 모듈은 불변하다고 간주되기에 이 패턴은 불가능합니다.
350+
왜냐하면 TypeScript는 로더에 구애받지 않기에, 이 정책이 컴파일-시간에 적용되지 않지만, ES6 모듈 로더로 전환하려는 개발자는 알고 있어야 합니다.
351351
352-
## The Impact of ES6 on Module Call Signatures
352+
## 모듈 호출 시그니처에 ES6가 미치는 영향 (The Impact of ES6 on Module Call Signatures)
353353
354-
Many popular libraries, such as Express, expose themselves as a callable function when imported.
355-
For example, the typical Express usage looks like this:
354+
Express와 같은 많은 유명한 라이브러리들은 import 될 때 호출 가능한 함수를 노출합니다.
355+
예를 들어, 일반적인 Express 사용법은 다음과 같습니다:
356356
357357
```ts
358358
import exp = require("express");
359359
var app = exp();
360360
```
361361
362-
In ES6 module loaders, the top-level object (here imported as `exp`) can only have properties;
363-
the top-level module object is *never* callable.
364-
The most common solution here is to define a `default` export for a callable/constructable object;
365-
some module loader shims will automatically detect this situation and replace the top-level object with the `default` export.
362+
ES6 모듈 로더에서, 최상위-레벨 객체(여기에서는 `exp`로 import)는 프로퍼티만 가질 수 있습니다;
363+
최상위-레벨 모듈 객체는 *절대* 호출할 수 없습니다.
364+
가장 일반적인 해결책은 호출 가능/생성 가능 객체를 `default` export로 정의하는 것입니다;
365+
어떤 모듈 로더 shims은 자동으로 이 상황을 감지하고 최상위-레벨 객체를 `default` export로 바꿉니다.
366366
367-
## Library file layout
367+
## 라이브러리 파일 레이아웃 (Library file layout)
368368
369-
The layout of your declaration files should mirror the layout of the library.
369+
선언 파일의 레이아웃은 라이브러리의 레이아웃을 반영해야 합니다.
370370
371-
A library can consist of multiple modules, such as
371+
라이브러리는 다음과 같이 여러 모듈로 구성됩니다
372372
373373
```Text
374374
myLib
@@ -379,7 +379,7 @@ myLib
379379
+---- baz.js
380380
```
381381
382-
These could be imported as
382+
이는 다음과 같이 import 할 수 있습니다
383383
384384
```js
385385
var a = require("myLib");
@@ -388,7 +388,7 @@ var c = require("myLib/bar");
388388
var d = require("myLib/bar/baz");
389389
```
390390
391-
Your declaration files should thus be
391+
그러므로 선언 파일은 다음과 같아야 합니다
392392
393393
```Text
394394
@types/myLib

0 commit comments

Comments
 (0)