You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: pages/declaration files/Library Structures.md
+9-9
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Broadly speaking, the way you *structure* your declaration file depends on how t
4
4
There are many ways of offering a library for consumption in JavaScript, and you'll need to write your declaration file to match it.
5
5
This guide covers how to identify common library patterns, and how to write declaration files which correspond to that pattern.
6
6
7
-
Each type of major library structuring pattern has a corresponding file in the [`templates`](./templates) directory.
7
+
Each type of major library structuring pattern has a corresponding file in the [`templates`](https://github.com/Microsoft/TypeScript-Handbook/tree/master/pages/declaration%20files/templates) directory.
8
8
You can start with these templates to help you get going faster.
9
9
10
10
# Identifying Kinds of Libraries
@@ -76,7 +76,7 @@ However, libraries that are small and require the DOM (or have *no* dependencies
76
76
77
77
### Global Library Template
78
78
79
-
The template file [`global.d.ts`](./templates/global.d.ts) defines an example library `myLib`.
79
+
The template file [`global.d.ts`](https://github.com/Microsoft/TypeScript-Handbook/tree/master/pages/declaration%20files/templates/global.d.ts) defines an example library `myLib`.
80
80
Be sure to read the ["Preventing Name Conflicts" footnote](#preventing-name-conflicts).
81
81
82
82
## Modular Libraries
@@ -176,9 +176,9 @@ Examples include [jQuery](https://jquery.com/), [Moment.js](http://momentjs.com/
176
176
### Template
177
177
178
178
There are three templates available for modules,
179
-
[`module.d.ts`](./templates/module.d.ts), [`module-class.d.ts`](./templates/module-class.d.ts) and [`module-function.d.ts`](./templates/module-function.d.ts).
179
+
[`module.d.ts`](https://github.com/Microsoft/TypeScript-Handbook/tree/master/pages/declaration%20files/templates/module.d.ts), [`module-class.d.ts`](https://github.com/Microsoft/TypeScript-Handbook/tree/master/pages/declaration%20files/templates/module-class.d.ts) and [`module-function.d.ts`](https://github.com/Microsoft/TypeScript-Handbook/tree/master/pages/declaration%20files/templates/module-function.d.ts).
180
180
181
-
Use [`module-function.d.ts`](./templates/module-function.d.ts) if your module can be *called* like a function:
181
+
Use [`module-function.d.ts`](https://github.com/Microsoft/TypeScript-Handbook/tree/master/pages/declaration%20files/templates/module-function.d.ts) if your module can be *called* like a function:
182
182
183
183
```ts
184
184
var x = require("foo");
@@ -188,7 +188,7 @@ var y = x(42);
188
188
189
189
Be sure to read the [footnote "The Impact of ES6 on Module Call Signatures"](#the-impact-of-es6-on-module-plugins)
190
190
191
-
Use [`module-class.d.ts`](./templates/module-class.d.ts) if your module can be *constructed* using `new`:
191
+
Use [`module-class.d.ts`](https://github.com/Microsoft/TypeScript-Handbook/tree/master/pages/declaration%20files/templates/module-class.d.ts) if your module can be *constructed* using `new`:
192
192
193
193
```ts
194
194
var x = require("bar");
@@ -198,7 +198,7 @@ var y = new x("hello");
198
198
199
199
The same [footnote](#the-impact-of-es6-on-module-plugins) applies to these modules.
200
200
201
-
If your module is not callable or constructable, use the [`module.d.ts`](./templates/module.d.ts) file.
201
+
If your module is not callable or constructable, use the [`module.d.ts`](https://github.com/Microsoft/TypeScript-Handbook/tree/master/pages/declaration%20files/templates/module.d.ts) file.
202
202
203
203
## *Module Plugin* or *UMDPlugin*
204
204
@@ -209,7 +209,7 @@ For the purposes of writing a declaration file, you'll write the same code wheth
209
209
210
210
### Template
211
211
212
-
Use the [`module-plugin.d.ts`](./templates/module-plugin.d.ts) template.
212
+
Use the [`module-plugin.d.ts`](https://github.com/Microsoft/TypeScript-Handbook/tree/master/pages/declaration%20files/templates/module-plugin.d.ts) template.
Use the [`global-plugin.d.ts`](./templates/global-plugin.d.ts) template.
239
+
Use the [`global-plugin.d.ts`](https://github.com/Microsoft/TypeScript-Handbook/tree/master/pages/declaration%20files/templates/global-plugin.d.ts) template.
Use the [`global-modifying-module.d.ts`](./templates/global-modifying-module.d.ts) template.
272
+
Use the [`global-modifying-module.d.ts`](https://github.com/Microsoft/TypeScript-Handbook/tree/master/pages/declaration%20files/templates/global-modifying-module.d.ts) template.
0 commit comments