Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Adds keywords page #342

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pages/Compiler Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Option | Type | Default
`--listEmittedFiles` | `boolean` | `false` | Print names of generated files part of the compilation.
`--listFiles` | `boolean` | `false` | Print names of files part of the compilation.
`--locale` | `string` | *(platform specific)* | The locale to use to show error messages, e.g. en-us.
`--mapRoot` | `string` | `null` | 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 than the .js files. The location specified will be embedded in the sourceMap to direct the debugger where the map files where be located.
`--mapRoot` | `string` | `null` | 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.
`--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.
`--moduleResolution` | `string` | `(module === 'amd' | 'system' | 'ES6' ? 'classic' : 'node')` | Determine how modules get resolved. Either `'node'` for Node.js/io.js style resolution, or `'classic'` (default). See [Module Resolution documentation](Module Resolution.md) for more details.
`--newLine` | `string` | *(platform specific)* | Use the specified end of line sequence to be used when emitting files: `'crlf'` (windows) or `'lf'` (unix)."
Expand Down Expand Up @@ -56,7 +56,7 @@ Option | Type | Default
`--skipLibCheck` | `boolean` | `false` | Don't check a the default library (`lib.d.ts`) file's valitidy.
`--skipDefaultLibCheck` | `boolean` | `false` | Don't check a user-defined default library (`*.d.ts`) file's valitidy.
`--sourceMap` | `boolean` | `false` | Generates corresponding '.map' file.
`--sourceRoot` | `string` | `null` | Specifies the location where debugger should locate TypeScript files instead of source locations. Use this flag if the sources will be located at run-time in a different location than that at design-time. The location specified will be embedded in the sourceMap to direct the debugger where the source files where be located.
`--sourceRoot` | `string` | `null` | Specifies the location where debugger should locate TypeScript files instead of source locations. Use this flag if the sources will be located at run-time in a different location than that at design-time. The location specified will be embedded in the sourceMap to direct the debugger where the source files will be located.
`--strictNullChecks` | `boolean` | `false` | In strict null checking mode, the `null` and `undefined` values are not in the domain of every type and are only assignable to themselves and `any` (the one exception being that `undefined` is also assignable to `void`).
`--stripInternal`<sup>[1]</sup> | `boolean` | `false` | Do not emit declarations for code that has an `/** @internal */` JSDoc annotation.
`--suppressExcessPropertyErrors` | `boolean` | `false` | Suppress excess property checks for object literals.
Expand Down
100 changes: 100 additions & 0 deletions pages/Keywords.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Typescript Keywords

The following keywords have the same meaning in Typescript as they do in Javascript:

Keyword | Notes
---|---
async, await | [ES draft](http://tc39.github.io/ecmascript-asyncawait/)
break | |
continue | |
class, extends, constructor, super | `extends` can also be used with `interface` |
const, let, var | `const`can also be used as a modifier for `enum`|
debugger | |
delete | |
do, while | |
export, import | |
for, each, in, of | |
function, return | |
get, set | |
if, else | |
instanceof, typeof | |
null, undefined | Can also refer to the `null` and `undefined` types|
switch, case, default | |
this | |
true, false | |
try, catch, finally | |
void | Can also refer to the `void` type |
yield | |

Unless otherwise noted, more information can be found on the [Mozilla Developer Network](https://developer.mozilla.org/en-US/docs/Web/JavaScript) or on [MSDN](https://msdn.microsoft.com/en-us/library/d1et7k7c%28v=vs.94%29.aspx)

---

The following keywords are used for [basic type annotations](http://www.typescriptlang.org/docs/handbook/basic-types.html):

Keyword | Description
---|---
any | [Describes a type unknown at design time](http://www.typescriptlang.org/docs/handbook/basic-types.html#any)
boolean | [Boolean](http://www.typescriptlang.org/docs/handbook/basic-types.html#boolean)
null | _Missing link_
never | _Missing link_
number | [Number](http://www.typescriptlang.org/docs/handbook/basic-types.html#number)
string | [String](http://www.typescriptlang.org/docs/handbook/basic-types.html#string)
symbol | [Symbol](http://www.typescriptlang.org/docs/handbook/symbols.html)
undefined | _Missing link_
void | _Missing link_

Other basic type-related keywords:

Keyword | Description
---|---
as | [Type assertion](http://www.typescriptlang.org/docs/handbook/basic-types.html#type-assetions)
is | _Missing link_

User-defined types:

Keyword | Description
---|---
enum | [Defines an enum](http://www.typescriptlang.org/docs/handbook/enums.html)
type | [Type aliases](http://www.typescriptlang.org/docs/handbook/advanced-types.html#type-aliases)
interface | [Defines the shape of a type (structural typing)](http://www.typescriptlang.org/docs/handbook/interfaces.html)

Modifiers on user-defined type:

Keyword | Description
---|---
abstract | [Abstract classes (cannot be instantiated; must be inherited)](http://www.typescriptlang.org/docs/handbook/classes.html#abstract-classes)
const | [Forces a const enum](http://www.typescriptlang.org/docs/handbook/enums.html)
implements | [Defines a class as implementing a given interface](http://www.typescriptlang.org/docs/handbook/interfaces.html#implementing-an-interface)

Modifiers on **members** of class/interface definitions:

Keyword | Description
---|---
abstract | [Inheriting classes must implement this method](http://www.typescriptlang.org/docs/handbook/classes.html#abstract-classes)
static | [Defines a member on the class, and not on the instance](http://www.typescriptlang.org/docs/handbook/classes.html#static-properties)
readonly | [Property can be read, but not written to](https://github.com/Microsoft/TypeScript/pull/6532)
private | [Property can be used only from its containing class](https://www.typescriptlang.org/docs/handbook/classes.html#understanding-private)
protected | [Property can only be used in its containing class, or by classes which inherit from the containing class](https://www.typescriptlang.org/docs/handbook/classes.html#understanding-protected)
public | [Property can be used from outside its containing class](https://www.typescriptlang.org/docs/handbook/classes.html#public-by-default)

---

Code organization and environment:

Keyword | Description
---|---
declare | [Ambient declarations -- elements created by the environment or other scripts](Missing link)
module | [Define an ambient module](http://www.typescriptlang.org/docs/handbook/modules.html#ambient-modules)
namespace | [Associates the contained types with the specified namespace](http://www.typescriptlang.org/docs/handbook/namespaces.html)
require | [Missing description](http://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require)

---

Unknown:

Keyword |
---|
from|
of|
package|
2 changes: 1 addition & 1 deletion pages/Modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ For example:
##### math-lib.d.ts

```ts
export const isPrime(x: number): boolean;'
export const isPrime(x: number): boolean;
export as namespace mathLib;
```

Expand Down
2 changes: 1 addition & 1 deletion pages/declaration files/Introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ For seasoned authors interested in the underlying mechanics of how declaration f

## `/templates`

In the `templates` directory, you'll find a number of declaration files that serve as a useful starting point
In the [`templates`](https://github.com/Microsoft/TypeScript-Handbook/tree/master/pages/declaration%20files/templates) directory, you'll find a number of declaration files that serve as a useful starting point
when writing a new file.
Refer to the documentation in [Library Structures](./Library Structures.md) to figure out which template file to use.

Expand Down
18 changes: 9 additions & 9 deletions pages/declaration files/Library Structures.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Broadly speaking, the way you *structure* your declaration file depends on how t
There are many ways of offering a library for consumption in JavaScript, and you'll need to write your declaration file to match it.
This guide covers how to identify common library patterns, and how to write declaration files which correspond to that pattern.

Each type of major library structuring pattern has a corresponding file in the [`templates`](./templates) directory.
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.
You can start with these templates to help you get going faster.

# Identifying Kinds of Libraries
Expand Down Expand Up @@ -76,7 +76,7 @@ However, libraries that are small and require the DOM (or have *no* dependencies

### Global Library Template

The template file [`global.d.ts`](./templates/global.d.ts) defines an example library `myLib`.
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`.
Be sure to read the ["Preventing Name Conflicts" footnote](#preventing-name-conflicts).

## Modular Libraries
Expand Down Expand Up @@ -176,9 +176,9 @@ Examples include [jQuery](https://jquery.com/), [Moment.js](http://momentjs.com/
### Template

There are three templates available for modules,
[`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).
[`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).

Use [`module-function.d.ts`](./templates/module-function.d.ts) if your module can be *called* like a function:
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:

```ts
var x = require("foo");
Expand All @@ -188,7 +188,7 @@ var y = x(42);

Be sure to read the [footnote "The Impact of ES6 on Module Call Signatures"](#the-impact-of-es6-on-module-plugins)

Use [`module-class.d.ts`](./templates/module-class.d.ts) if your module can be *constructed* using `new`:
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`:

```ts
var x = require("bar");
Expand All @@ -198,7 +198,7 @@ var y = new x("hello");

The same [footnote](#the-impact-of-es6-on-module-plugins) applies to these modules.

If your module is not callable or constructable, use the [`module.d.ts`](./templates/module.d.ts) file.
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.

## *Module Plugin* or *UMD Plugin*

Expand All @@ -209,7 +209,7 @@ For the purposes of writing a declaration file, you'll write the same code wheth

### Template

Use the [`module-plugin.d.ts`](./templates/module-plugin.d.ts) template.
Use the [`module-plugin.d.ts`](https://github.com/Microsoft/TypeScript-Handbook/tree/master/pages/declaration%20files/templates/module-plugin.d.ts) template.

## *Global Plugin*

Expand All @@ -236,7 +236,7 @@ console.log(y.reverseAndSort());

### Template

Use the [`global-plugin.d.ts`](./templates/global-plugin.d.ts) template.
Use the [`global-plugin.d.ts`](https://github.com/Microsoft/TypeScript-Handbook/tree/master/pages/declaration%20files/templates/global-plugin.d.ts) template.

## *Global-modifying Modules*

Expand Down Expand Up @@ -269,7 +269,7 @@ console.log(y.reverseAndSort());

### Template

Use the [`global-modifying-module.d.ts`](./templates/global-modifying-module.d.ts) template.
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.

# Consuming Dependencies

Expand Down