Skip to content

Commit 53e8ded

Browse files
committed
init translation of consumption
1 parent 8353b02 commit 53e8ded

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

docs/documentation/zh/declaration-files/Consumption.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,41 @@
22
title: Consumption
33
layout: docs
44
permalink: /zh/docs/handbook/declaration-files/consumption.html
5-
oneline: "How to download d.ts files for your project"
5+
oneline: "如何下载 .d.ts 文件以供你的项目使用"
66
---
77

8-
## Downloading
8+
## 下载
99

10-
Getting type declarations requires no tools apart from npm.
10+
你只需 npm 即可获取类型声明。
1111

12-
As an example, getting the declarations for a library like lodash takes nothing more than the following command
12+
例如,仅需以下命令即可获得类似 lodash 这样库的声明文件
1313

1414
```cmd
1515
npm install --save-dev @types/lodash
1616
```
1717

18-
It is worth noting that if the npm package already includes its declaration file as described in [Publishing](/zh/docs/handbook/declaration-files/publishing.html), downloading the corresponding `@types` package is not needed.
18+
值得注意的是,如果 npm 包已经包含其声明文件,如[发布](/zh/docs/handbook/declaration-files/publishing.html)中所述,那么不需要下载相应的 `@types` 包。
1919

20-
## Consuming
20+
## 使用
2121

22-
From there you’ll be able to use lodash in your TypeScript code with no fuss.
23-
This works for both modules and global code.
22+
之后,你就可以在 TypeScript 代码中轻松使用 lodash。这适用于模块和全局代码。
2423

25-
For example, once you’ve `npm install`-ed your type declarations, you can use imports and write
24+
例如,一旦你通过 `npm install` 安装了类型声明,你就可以使用导入并编写
2625

2726
```ts
2827
import * as _ from "lodash";
2928
_.padStart("Hello TypeScript!", 20, " ");
3029
```
3130

32-
or if you’re not using modules, you can just use the global variable `_`.
31+
或者,如果你不使用模块,你可以直接使用全局变量 `_`
3332

3433
```ts
3534
_.padStart("Hello TypeScript!", 20, " ");
3635
```
3736

38-
## Searching
37+
## 搜索
3938

40-
For the most part, type declaration packages should always have the same name as the package name on `npm`, but prefixed with `@types/`,
41-
but if you need, you can use the [Yarn package search](https://yarnpkg.com/) to find the package for your favorite library.
39+
在大多数情况下,类型声明包的名称应与 `npm` 上的包名称相同,但前缀为 `@types/`,但如果需要,你可以使用 [Yarn 包搜索](https://yarnpkg.com/)来查找你喜欢的库的包。
4240

43-
> Note: if the declaration file you are searching for is not present, you can always contribute one back and help out the next developer looking for it.
44-
> Please see the DefinitelyTyped [contribution guidelines page](https://definitelytyped.org/guides/contributing.html) for details.
41+
> 注意:如果你正在搜索的声明文件不存在,你可以随时贡献并帮助下一个寻找它的开发人员。
42+
> 请参阅 DefinitelyTyped [贡献指南页面](https://definitelytyped.org/guides/contributing.html)以获取详细信息。"

0 commit comments

Comments
 (0)