Skip to content

Commit 442257f

Browse files
authored
init translation of module.class.d.ts (#102)
1 parent f8aef20 commit 442257f

File tree

1 file changed

+31
-32
lines changed

1 file changed

+31
-32
lines changed

Diff for: docs/documentation/zh/declaration-files/templates/module-class.d.ts.md

+31-32
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
2-
title: "Module: Class"
3-
layout: docs
2+
title: "模块:类"
3+
layout: 文档
44
permalink: /zh/docs/handbook/declaration-files/templates/module-class-d-ts.html
55
---
66

77
<!--
88
TODO:
99
10-
1. Not clear why UMD is thrown in here.
11-
2. Give both commonjs and ES module examples.
10+
1. 不清楚为什么在这里加入 UMD
11+
2. 给出 CommonJS 和 ES 模块的示例。
1212
-->
1313

14-
For example, when you want to work with JavaScript code which looks like:
14+
例如,当你希望使用类似以下 JavaScript 代码时:
1515

1616
```ts
1717
const Greeter = require("super-greeter");
@@ -20,44 +20,43 @@ const greeter = new Greeter();
2020
greeter.greet();
2121
```
2222

23-
To handle both importing via UMD and modules:
23+
处理通过 UMD 和模块导入的情况:
2424

2525
```ts
26-
// Type definitions for [~THE LIBRARY NAME~] [~OPTIONAL VERSION NUMBER~]
27-
// Project: [~THE PROJECT NAME~]
28-
// Definitions by: [~YOUR NAME~] <[~A URL FOR YOU~]>
26+
// 类型定义为 [~THE LIBRARY NAME~] [~OPTIONAL VERSION NUMBER~]
27+
// 项目: [~THE PROJECT NAME~]
28+
// 定义者: [~YOUR NAME~] <[~A URL FOR YOU~]>
2929

30-
/*~ This is the module template file for class modules.
31-
*~ You should rename it to index.d.ts and place it in a folder with the same name as the module.
32-
*~ For example, if you were writing a file for "super-greeter", this
33-
*~ file should be 'super-greeter/index.d.ts'
30+
/*~ 这是用于类模块的模块模板文件。
31+
*~ 你应该将其重命名为 index.d.ts,并将其放在与模块同名的文件夹中。
32+
*~ 例如,如果你为 "super-greeter" 编写一个文件,此
33+
*~ 文件应该是 'super-greeter/index.d.ts'
3434
*/
3535

36-
// Note that ES6 modules cannot directly export class objects.
37-
// This file should be imported using the CommonJS-style:
36+
// 请注意,ES6 模块无法直接导出类对象。
37+
// 该文件应该使用 CommonJS 风格导入:
3838
// import x = require('[~THE MODULE~]');
3939
//
40-
// Alternatively, if --allowSyntheticDefaultImports or
41-
// --esModuleInterop is turned on, this file can also be
42-
// imported as a default import:
40+
// 或者,如果 --allowSyntheticDefaultImports 或
41+
// --esModuleInterop 打开,该文件也可以作为默认导入导入:
4342
// import x from '[~THE MODULE~]';
4443
//
45-
// Refer to the TypeScript documentation at
44+
// 请参阅 TypeScript 文档
4645
// https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require
47-
// to understand common workarounds for this limitation of ES6 modules.
46+
// 了解 ES6 模块的此限制的常见解决方法。
4847

49-
/*~ If this module is a UMD module that exposes a global variable 'myClassLib' when
50-
*~ loaded outside a module loader environment, declare that global here.
51-
*~ Otherwise, delete this declaration.
48+
/*~ 如果此模块是一个 UMD 模块,在加载到模块加载器环境之外时公开全局变量 'myClassLib'
49+
*~ 请在此处声明该全局变量。
50+
*~ 否则,请删除此声明。
5251
*/
5352
export as namespace "super-greeter";
5453

55-
/*~ This declaration specifies that the class constructor function
56-
*~ is the exported object from the file
54+
/*~ 此声明指定类构造函数
55+
*~ 是文件中导出的对象
5756
*/
5857
export = Greeter;
5958

60-
/*~ Write your module's methods and properties in this class */
59+
/*~ 在此类中编写你模块的方法和属性 */
6160
declare class Greeter {
6261
constructor(customGreeting?: string);
6362

@@ -66,13 +65,13 @@ declare class Greeter {
6665
myMethod(opts: MyClass.MyClassMethodOptions): number;
6766
}
6867

69-
/*~ If you want to expose types from your module as well, you can
70-
*~ place them in this block.
68+
/*~ 如果你还想公开模块的类型,你可以
69+
*~ 将它们放在此块中。
7170
*~
72-
*~ Note that if you decide to include this namespace, the module can be
73-
*~ incorrectly imported as a namespace object, unless
74-
*~ --esModuleInterop is turned on:
75-
*~ import * as x from '[~THE MODULE~]'; // WRONG! DO NOT DO THIS!
71+
*~ 请注意,如果决定包含此命名空间,则可能会
72+
*~ 错误地将模块导入为命名空间对象,除非
73+
*~ 打开了 --esModuleInterop
74+
*~ import * as x from '[~THE MODULE~]'; // 错误!不要这样做!
7675
*/
7776
declare namespace MyClass {
7877
export interface MyClassMethodOptions {

0 commit comments

Comments
 (0)