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
Copy file name to clipboardExpand all lines: pages/Compiler Options.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ Option | Type | Default
22
22
`--inlineSourceMap` | `boolean` | `false` | Emit a single file with source maps instead of having a separate file.
23
23
`--inlineSources` | `boolean` | `false` | Emit the source alongside the sourcemaps within a single file; requires `--inlineSourceMap` or `--sourceMap` to be set.
24
24
`--init` | | | Initializes a TypeScript project and creates a `tsconfig.json` file.
`--isolatedModules` | `boolean` | `false` | Transpile each file as a separate module (similar to "ts.transpileModule").
26
26
`--jsx` | `string` | `"Preserve"` | Support JSX in `.tsx` files: `"React"` or `"Preserve"`. See [JSX](./JSX.md).
27
27
`--jsxFactory` | `string` | `"React.createElement"` | Specify the JSX factory function to use when targeting react JSX emit, e.g. `React.createElement` or `h`.
28
28
`--lib` | `string[]`| | List of library files to be included in the compilation.<br/>Possible values are: <br/>► `ES5` <br/>► `ES6` <br/>► `ES2015` <br/>► `ES7` <br/>► `ES2016` <br/>► `ES2017` <br/>► `DOM` <br/>► `DOM.Iterable` <br/>► `WebWorker` <br/>► `ScriptHost` <br/>► `ES2015.Core` <br/>► `ES2015.Collection` <br/>► `ES2015.Generator` <br/>► `ES2015.Iterable` <br/>► `ES2015.Promise` <br/>► `ES2015.Proxy` <br/>► `ES2015.Reflect` <br/>► `ES2015.Symbol` <br/>► `ES2015.Symbol.WellKnown` <br/>► `ES2016.Array.Include` <br/>► `ES2017.object` <br/>► `ES2017.SharedMemory` <br/><br/> Note: If `--lib` is not specified a default library is injected. The default library injected is: <br/> ► For `--target ES5`: `DOM,ES5,ScriptHost`<br/> ► For `--target ES6`: `DOM,ES6,DOM.Iterable,ScriptHost`
@@ -31,7 +31,7 @@ Option | Type | Default
31
31
`--locale` | `string` | *(platform specific)* | The locale to use to show error messages, e.g. en-us.
32
32
`--mapRoot` | `string` | | Specifies the location where debugger should locate map files instead of generated locations. Use this flag if the .map files will be located at run-time in a different location than the .js files. The location specified will be embedded in the sourceMap to direct the debugger where the map files will be located.
33
33
`--maxNodeModuleJsDepth` | `number` | `0` | The maximum dependency depth to search under node_modules and load JavaScript files. Only applicable with `--allowJs`.
34
-
`--module`<br/>`-m` | `string` | `target === "ES6" ? "ES6" : "CommonJS"` | Specify module code generation: `"None"`, `"CommonJS"`, `"AMD"`, `"System"`, `"UMD"`, `"ES6"`, or `"ES2015"`.<br/>► Only `"AMD"` and `"System"` can be used in conjunction with `--outFile`.<br/>► `"ES6"` and `"ES2015"` values may not be used when targeting `"ES5"` or lower.
34
+
`--module`<br/>`-m` | `string` | `target === "ES6" ? "ES6" : "CommonJS"` | Specify module code generation: `"None"`, `"CommonJS"`, `"AMD"`, `"System"`, `"UMD"`, `"ES6"`, or `"ES2015"`.<br/>► Only `"AMD"` and `"System"` can be used in conjunction with `--outFile`.<br/>► `"ES6"` and `"ES2015"` values may be used when targeting `"ES5"` or lower.
35
35
`--moduleResolution` | `string` | `module === "AMD" | "System" | "ES6" ? "Classic" : "Node"` | Determine how modules get resolved. Either `"Node"` for Node.js/io.js style resolution, or `"Classic"`. See [Module Resolution documentation](./Module Resolution.md) for more details.
36
36
`--newLine` | `string` | *(platform specific)* | Use the specified end of line sequence to be used when emitting files: `"crlf"` (windows) or `"lf"` (unix)."
37
37
`--noEmit` | `boolean` | `false` | Do not emit outputs.
Copy file name to clipboardExpand all lines: pages/Decorators.md
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
With the introduction of Classes in TypeScript and ES6, there now exist certain scenarios that require additional features to support annotating or modifying classes and class members.
4
4
Decorators provide a way to add both annotations and a meta-programming syntax for class declarations and members.
5
-
Decorators are a [stage 1 proposal](https://github.com/wycats/javascript-decorators/blob/master/README.md) for JavaScript and are available as an experimental feature of TypeScript.
5
+
Decorators are a [stage 2 proposal](https://github.com/tc39/proposal-decorators) for JavaScript and are available as an experimental feature of TypeScript.
6
6
7
7
> NOTE  Decorators are an experimental feature that may change in future releases.
8
8
@@ -163,6 +163,28 @@ function sealed(constructor: Function) {
163
163
164
164
When `@sealed` is executed, it will seal both the constructor and its prototype.
165
165
166
+
Next we have a example how to override the constructor.
167
+
168
+
```ts
169
+
function classDecorator<Textends {new(...args:any[]):{}}>(constructor:T) {
170
+
returnclassextendsconstructor {
171
+
newProperty ="new property";
172
+
hello ="override";
173
+
}
174
+
}
175
+
176
+
@classDecorator
177
+
classGreeter {
178
+
property ="property";
179
+
hello:string;
180
+
constructor(m:string) {
181
+
this.hello=m;
182
+
}
183
+
}
184
+
185
+
console.log(newGreeter("world"));
186
+
```
187
+
166
188
## Method Decorators
167
189
168
190
A *Method Decorator* is declared just before a method declaration.
Copy file name to clipboardExpand all lines: pages/Interfaces.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -143,7 +143,7 @@ Variables use `const` whereas properties use `readonly`.
143
143
144
144
# Excess Property Checks
145
145
146
-
In our first example using interfaces, TypeScript let us pass `{ size: number; label: string; }` to something that only expected a `{ label: string; }`.
146
+
In our first example using interfaces, TypeScript lets us pass `{ size: number; label: string; }` to something that only expected a `{ label: string; }`.
147
147
We also just learned about optional properties, and how they're useful when describing so-called "option bags".
148
148
149
149
However, combining the two naively would let you to shoot yourself in the foot the same way you might in JavaScript.
Copy file name to clipboardExpand all lines: pages/JSX.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,16 +12,18 @@ In order to use JSX you must do two things.
12
12
1. Name your files with a `.tsx` extension
13
13
2. Enable the `jsx` option
14
14
15
-
TypeScript ships with two JSX modes: `preserve`and `react`.
15
+
TypeScript ships with three JSX modes: `preserve`, `react`, and `react-native`.
16
16
These modes only affect the emit stage - type checking is unaffected.
17
17
The `preserve` mode will keep the JSX as part of the output to be further consumed by another transform step (e.g. [Babel](https://babeljs.io/)).
18
18
Additionally the output will have a `.jsx` file extension.
19
19
The `react` mode will emit `React.createElement`, does not need to go through a JSX transformation before use, and the output will have a `.js` file extension.
20
+
The `react-native` mode is the equivalent of `preserve` in that it keeps all JSX, but the output will instead have a `.js` file extension.
Copy file name to clipboardExpand all lines: pages/Module Resolution.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ Any other import is considered **non-relative**.
33
33
Some examples include:
34
34
35
35
*`import * as $ from "jquery";`
36
-
*`import { Component } from "angular2/core";`
36
+
*`import { Component } from "@angular/core";`
37
37
38
38
A relative import is resolved relative to the importing file and *cannot* resolve to an ambient module declaration.
39
39
You should use relative imports for your own modules that are guaranteed to maintain their relative location at runtime.
@@ -199,13 +199,13 @@ Value of *baseUrl* is determined as either:
199
199
200
200
Note that relative module imports are not impacted by setting the baseUrl, as they are always resolved relative to their importing files.
201
201
202
-
You can find more documentation on baseUrl in [RequireJS](http://requirejs.org/docs/api.html#config-baseUrl) and [SystemJS](https://github.com/systemjs/systemjs/blob/master/docs/overview.md#baseurl) documentation.
202
+
You can find more documentation on baseUrl in [RequireJS](http://requirejs.org/docs/api.html#config-baseUrl) and [SystemJS](https://github.com/systemjs/systemjs/blob/master/docs/config-api.md#baseurl) documentation.
203
203
204
204
### Path mapping
205
205
206
206
Sometimes modules are not directly located under *baseUrl*.
207
207
For instance, an import to a module `"jquery"` would be translated at runtime to `"node_modules\jquery\dist\jquery.slim.min.js"`.
208
-
Loaders use a mapping configuration to map module names to files at run-time, see [RequireJs documentation](http://requirejs.org/docs/api.html#config-paths) and [SystemJS documentation](https://github.com/systemjs/systemjs/blob/master/docs/overview.md#map-config).
208
+
Loaders use a mapping configuration to map module names to files at run-time, see [RequireJs documentation](http://requirejs.org/docs/api.html#config-paths) and [SystemJS documentation](https://github.com/systemjs/systemjs/blob/master/docs/config-api.md#paths).
209
209
210
210
The TypeScript compiler supports the declaration of such mappings using `"paths"` property in `tsconfig.json` files.
211
211
Here is an example for how to specify the `"paths"` property for `jquery`.
Copy file name to clipboardExpand all lines: pages/release notes/TypeScript 2.1.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -452,7 +452,7 @@ var Derived = (function (_super) {
452
452
}(Base));
453
453
```
454
454
455
-
> This change entails a break in the behavior of extending built-in classes like `Error`, `Array`, `Map`, etc.. Please see the [extending built-ins breaking change documnetation](https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work) for more details.
455
+
> This change entails a break in the behavior of extending built-in classes like `Error`, `Array`, `Map`, etc.. Please see the [extending built-ins breaking change documentation](https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work) for more details.
0 commit comments