Skip to content

Commit 53264ad

Browse files
committed
add errors 1063-1092
1 parent 561c988 commit 53264ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+408
-175
lines changed

deno.json

-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
]
1818
}
1919
},
20-
"fmt": {
21-
"exclude": ["./docs/*"]
22-
},
2320
"exclude": [
2421
"**/_fresh/*"
2522
],

docs/1003.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Identifier expected.
2+
title: "Identifier expected."
33
category: error
44
tags:
55
- syntax-error

docs/1030.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ tags:
88
Modifiers can only appear once per property. If a modifier is repeated, an error
99
will be shown:
1010

11+
<!-- deno-fmt-ignore-start -->
1112
```ts
1213
class A {
1314
readonly readonly x: string;
1415
}
1516
```
17+
<!-- deno-fmt-ignore-end -->

docs/1063.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
---
22
title: "An export assignment cannot be used in a namespace."
33
category: error
4+
tags:
5+
- typescript-only
6+
- namespace
7+
- export-assignment
48
---
59

610
Namespaces are defined in TypeScript with an object which may have properties.

docs/1064.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
---
22
title: "The return type of an async function or method must be the global Promise<T> type. Did you mean to write 'Promise<{0}>'?"
33
category: error
4+
tags:
5+
- promise
6+
- async
7+
related:
8+
- 1055
49
---
10+
11+
Async functions which try to declare non-promise return type will throw this
12+
error, because async functions and methods _always_ return a promise:
13+
14+
```ts
15+
class A {
16+
async method(): number {
17+
return 1;
18+
}
19+
}
20+
```

docs/1064_fix_01.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: "Correct the return type"
3+
---
4+
5+
Correct the return type:
6+
7+
```ts
8+
class A {
9+
async method(): Promise<number> {
10+
return 1;
11+
}
12+
}
13+
```

docs/1066.md

+15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
---
22
title: "In ambient enum declarations member initializer must be constant expression."
33
category: error
4+
tags:
5+
- typescript
6+
- enum
7+
- initializer
48
---
9+
10+
While valid in `.ts` files, using a variable as an enum initializer is not
11+
allowed in type declaration files (`.d.ts`):
12+
13+
```ts
14+
declare const aVal = 1;
15+
16+
export enum A {
17+
a = aVal;
18+
}
19+
```

docs/1066_fix_01.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
title: "Use a const value initializer."
3+
---
4+
5+
Move the value into the `enum`:
6+
7+
```ts
8+
declare const aVal = 1;
9+
10+
export enum A {
11+
a = 1; /* aVal */
12+
}
13+
```

docs/1068.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
---
22
title: "Unexpected token. A constructor, method, accessor, or property was expected."
33
category: error
4+
tags:
5+
- syntax-error
46
---
7+
8+
This error indicates that your syntax is incorrect. You likely have an
9+
additional keyword which is unnecessary:
10+
11+
```ts
12+
class A {
13+
function method() {}
14+
}
15+
```

docs/1068_fix_01.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: "Correct the syntax."
3+
---
4+
5+
To fix the error, correct the syntax:
6+
7+
```ts
8+
class A {
9+
method() {}
10+
}
11+
```

docs/1069.md

+20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
---
22
title: "Unexpected token. A type parameter name was expected without curly braces."
33
category: error
4+
tags:
5+
- jsdoc
6+
- javascript
7+
- type-parameters
48
---
9+
10+
When using the `@template` tag, the parser looks for code like
11+
`@template {Constraint} T,U,V`. The names of the generic parameters are not
12+
included in braces:
13+
14+
```js
15+
// @ts-check
16+
17+
/**
18+
* @template {string} {T}
19+
* @param {T} arg
20+
*/
21+
function identity(arg) {
22+
return arg;
23+
}
24+
```

docs/1069_fix_01.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: "Remove braces from generic name."
3+
---
4+
5+
Remove the braces from the names of the generic parameters:
6+
7+
```js
8+
// @ts-check
9+
10+
/**
11+
* @template {string} T
12+
* @param {T} arg
13+
*/
14+
function identity(arg) {
15+
return arg;
16+
}
17+
```

docs/1070.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
---
22
title: "'{0}' modifier cannot appear on a type member."
33
category: error
4+
tags:
5+
- types
6+
- typescript-only
7+
- modifiers
48
---
9+
10+
When defining a type, no modifiers (except `readonly`) can be applied to its
11+
type members:
12+
13+
```ts
14+
interface A {
15+
async a(): Promise<string>;
16+
public b(): string;
17+
private c(): string;
18+
protected d(): string;
19+
}
20+
```

docs/1070_fix_01.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: "Remove the modifier."
3+
---
4+
5+
Remove the modifiers:
6+
7+
```ts
8+
interface A {
9+
a(): Promise<string>;
10+
b(): string;
11+
c(): string;
12+
d(): string;
13+
}
14+
```

docs/1071.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
---
22
title: "'{0}' modifier cannot appear on an index signature."
33
category: error
4+
tags:
5+
- types
6+
- typescript-only
7+
- modifiers
48
---
9+
10+
When defining a type, no modifiers (except `readonly`) can be applied to its
11+
index signature:
12+
13+
```ts
14+
interface A {
15+
public [x: string]: string;
16+
}
17+
```

docs/1071_fix_01.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: "Remove the modifier."
3+
---
4+
5+
Remove the modifiers:
6+
7+
```ts
8+
interface A {
9+
[x: string]: string;
10+
}
11+
```

docs/1079.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
---
22
title: "A '{0}' modifier cannot be used with an import declaration."
33
category: error
4+
tags:
5+
- declarations
6+
- typescript-only
47
---
8+
9+
Whether in a declaration file or a regular TypeScript file, imports are already
10+
declared, so it doesn't make sense to add the `declare` keyword to the import:
11+
12+
```ts
13+
declare import * as ts from "typescript";
14+
```

docs/1079_fix_01.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: "Remove declare keyword."
3+
---
4+
5+
Remove the declare keyword:
6+
7+
```ts
8+
import * as ts from "typescript";
9+
```

docs/1084.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
---
22
title: "Invalid 'reference' directive syntax."
33
category: error
4+
tags:
5+
- syntax-error
6+
- typescript-only
7+
- triple-slash
48
---
9+
10+
When using triple slash references, the tag must contain a `path`, `types`,
11+
`lib`, or `no-default-lib` key. If the tag does not include any of these keys,
12+
this error will be reported:
13+
14+
```ts
15+
/// <reference />
16+
```

docs/1084_fix_01.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: "Use a valid reference directive."
3+
---
4+
5+
To fix the error, complete the tag by adding a valid key:
6+
7+
```ts
8+
/// <reference path="./some-file" />
9+
/// <reference types="node" />
10+
/// <reference lib="es2015" />
11+
/// <reference no-default-lib="true"/>
12+
```
13+
14+
Also see
15+
[Triple-Slash Directives](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html)
16+
in the TypeScript Handbook.

docs/1085.md

-4
This file was deleted.

docs/1089.md

+22
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
11
---
22
title: "'{0}' modifier cannot appear on a constructor declaration."
33
category: error
4+
tags:
5+
- constructors
6+
- modifiers
7+
- syntax-error
48
---
9+
10+
Some modifiers cannot be applied to class constructors:
11+
12+
```ts
13+
class A {
14+
static constructor()
15+
abstract constructor()
16+
async constructor()
17+
readonly constructor() {}
18+
}
19+
```
20+
21+
Static constructor methods cannot be named `constructor` as the `constructor`
22+
property already exists on objects and refer to the constructor of the object.
23+
`create` is a common alternative name. Similarly, `async` can be applied to a
24+
`static` "constructor". Marking a constructor as `abstract` doesn't make sense
25+
since `abstract` only refers to members of the instance of a class. Constructors
26+
cannot be assigned to, so `readonly` doesn't make sense.

docs/1089_fix_01.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
type: "Remove the constructor modifier."
3+
---
4+
5+
Remove the constructor modifier:
6+
7+
```ts
8+
class A {
9+
static create(): A;
10+
11+
static async createAsync(): Promise<A>;
12+
13+
constructor() {}
14+
}
15+
```

docs/1090.md

+15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
---
22
title: "'{0}' modifier cannot appear on a parameter."
33
category: error
4+
tags:
5+
- constructors
6+
- parameters
7+
- modifiers
8+
- syntax-error
49
---
10+
11+
Some modifiers can be added to constructor parameters in order to automatically
12+
declare the parameter as an element of the class. If you try to use an invalid
13+
modifier, this error will occur:
14+
15+
```ts
16+
class A {
17+
constructor(static param: string) {}
18+
}
19+
```

docs/1090_fix_01.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: "Refactor code to remove modifier."
3+
---
4+
5+
Replace the modifier with the explicit code you were hoping TypeScript would
6+
generate.
7+
8+
```ts
9+
class A {
10+
static param: string = "";
11+
12+
constructor(param: string) {
13+
A.param = param;
14+
}
15+
}
16+
```

0 commit comments

Comments
 (0)