Skip to content

Commit

Permalink
Replace $ExpectError with @ts-expect-error (DefinitelyTyped#60697)
Browse files Browse the repository at this point in the history
  • Loading branch information
jablko authored Jun 24, 2022
1 parent 13bc629 commit 0d30235
Show file tree
Hide file tree
Showing 920 changed files with 9,039 additions and 6,136 deletions.
6 changes: 3 additions & 3 deletions README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,21 +199,21 @@ const result = twoslash("//")
+ // Handle options param
+ const resultWithOptions = twoslash("//", { version: "3.7" })
+ // When the param is incorrect
+ // $ExpectError
+ // @ts-expect-error
+ const resultWithOptions = twoslash("//", { })
```

If you're wondering where to start with test code, the examples in the README of the module are a great place to start.

You can [validate your changes](#running-tests) with `npm test <package to test>` from the root of this repo, which takes changed files into account.

Para afirmar que una expresión es de un tipo dado, utilice `$ExpectType`. Para afirmar que una expresión causa un error de compilación, utilice `$ExpectError`.
Para afirmar que una expresión es de un tipo dado, utilice `$ExpectType`. Para afirmar que una expresión causa un error de compilación, utilice `@ts-expect-error`.

```js
// $ExpectType void
f(1);

// $ExpectError
// @ts-expect-error
f("one");
```

Expand Down
9 changes: 5 additions & 4 deletions README.it.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,20 @@ const result = twoslash("//")
+ // Handle options param
+ const resultWithOptions = twoslash("//", { version: "3.7" })
+ // When the param is incorrect
+ // $ExpectError
+ // @ts-expect-error
+ const resultWithOptions = twoslash("//", { })
```

Se ti stai chiedendo da dove cominciare per fare i test, gli esempi nel README del modulo sono un buon punto da dove partire.

Puoi [validare le tue modifiche](#eseguire-test) con `npm test <package da testare>` nella root di questa repo, che prende in considerazione i file cambiati.
Usa `$ExpectType` per asserire che un'espressione è del tipo dato e `$ExpectError` per asserire un errore di compilazione. Ad esempio:
Usa `$ExpectType` per asserire che un'espressione è del tipo dato e `@ts-expect-error` per asserire un errore di compilazione. Ad esempio:

```js
// $ExpectType void
f(1);

// $ExpectError
// @ts-expect-error
f("one");
```

Expand Down Expand Up @@ -290,7 +290,8 @@ Se un file non è nè testato nè riferito nell'`index.d.ts`, aggiungilo in un f
* Formattazione: Usa 4 spazi. Prettier è abilitato su questa repo, quindi puoi eseguire `npm run prettier -- --write path/to/package/**/*.ts`. [Quando usi le assertion](https://github.com/SamVerschueren/tsd#assertions), aggiungi `// prettier-ignore` per marcare le linee di codice da escludere quando si fa la formattazione:
```tsx
// prettier-ignore
const incompleteThemeColorModes: Theme = { colors: { modes: { papaya: { // $ExpectError
// @ts-expect-error
const incompleteThemeColorModes: Theme = { colors: { modes: { papaya: {
```
* `function sum(nums: number[]): number`: Usa `ReadonlyArray` se una funzione non modifica i suoi parametri.
* `interface Foo { new(): Foo; }`:
Expand Down
9 changes: 5 additions & 4 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,21 +224,21 @@ const result = twoslash("//")
+ // オプションの引数に対応
+ const resultWithOptions = twoslash("//", { version: "3.7" })
+ // 引数が正しくないとき
+ // $ExpectError
+ // @ts-expect-error
+ const resultWithOptions = twoslash("//", { })
```

もしどこからテストコードを書き始めればよいかわからないときは、そのモジュールの README に書かれてるサンプルをテストするコードから始めるのがよいでしょう。

レポジトリのルートで `npm test <テストしたいパッケージ名>` を実行すると、このコマンドはファイルが変更された状態でテストを実行するので、[変更を検証](#テストの実行)することができます。

式が与えられた型であるか確認するには `$ExpectType` を、コンパイルエラーになるかを確認するには `$ExpectError` をそれぞれ使います。 例:
式が与えられた型であるか確認するには `$ExpectType` を、コンパイルエラーになるかを確認するには `@ts-expect-error` をそれぞれ使います。 例:

```js
// $ExpectType void
f(1);

// $ExpectError
// @ts-expect-error
f("one");
```

Expand Down Expand Up @@ -272,7 +272,8 @@ DefinitelyTyped 外のモジュールに依存しないパッケージについ
* フォーマットについて: 4個のスペースを使ってください。このレポジトリでは Prettier がセットアップされているので、 `npm run prettier -- --write path/to/package/**/*.ts` で実行できます。[アサーションを使用している場合](https://github.com/SamVerschueren/tsd#assertions)`// prettier-ignore` を使ってその行をフォーマット対象から除外してください。
```tsx
// prettier-ignore
const incompleteThemeColorModes: Theme = { colors: { modes: { papaya: { // $ExpectError
// @ts-expect-error
const incompleteThemeColorModes: Theme = { colors: { modes: { papaya: {
```
* `function sum(nums: number[]): number`: 関数が引数に対して書き込まないときは `ReadonlyArray` を使用してください。
* `interface Foo { new(): Foo; }`:
Expand Down
6 changes: 3 additions & 3 deletions README.ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,21 +225,21 @@ const result = twoslash("//")
+ // Handle options param
+ const resultWithOptions = twoslash("//", { version: "3.7" })
+ // When the param is incorrect
+ // $ExpectError
+ // @ts-expect-error
+ const resultWithOptions = twoslash("//", { })
```

If you're wondering where to start with test code, the examples in the README of the module are a great place to start.

You can [validate your changes](#검증하기) with `npm test <package to test>` from the root of this repo, which takes changed files into account.

어떤 표현식(Expression)이 특정한 형(Type)을 가진다고 단언(Assert)하고 싶을 때에는 `$ExpectType` 를 사용하시면 됩니다. 어떤 표현식(Expression)이 컴파일에 실패해야하는 경우에는 `$ExpectError` 를 하시면 됩니다.
어떤 표현식(Expression)이 특정한 형(Type)을 가진다고 단언(Assert)하고 싶을 때에는 `$ExpectType` 를 사용하시면 됩니다. 어떤 표현식(Expression)이 컴파일에 실패해야하는 경우에는 `@ts-expect-error` 를 하시면 됩니다.

```js
// $ExpectType void
f(1);

// $ExpectError
// @ts-expect-error
f("one");
```

Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,21 +260,21 @@ const result = twoslash("//")
+ // Handle options param
+ const resultWithOptions = twoslash("//", { version: "3.7" })
+ // When the param is incorrect
+ // $ExpectError
+ // @ts-expect-error
+ const resultWithOptions = twoslash("//", { })
```

If you're wondering where to start with test code, the examples in the README of the module are a great place to start.

You can [validate your changes](#running-tests) with `npm test <package to test>` from the root of this repo, which takes changed files into account.

Use `$ExpectType` to assert that an expression is of a given type, and `$ExpectError` to assert that a compile error. Examples:
Use `$ExpectType` to assert that an expression is of a given type, and `@ts-expect-error` to assert that a compile error. Examples:

```js
// $ExpectType void
f(1);
// $ExpectError
// @ts-expect-error
f("one");
```

Expand Down Expand Up @@ -340,7 +340,8 @@ If a file is neither tested nor referenced in `index.d.ts`, add it to a file nam
* Formatting: Use 4 spaces. Prettier is set up on this repo, so you can run `npm run prettier -- --write path/to/package/**/*.ts`. [When using assertions](https://github.com/SamVerschueren/tsd#assertions), add `// prettier-ignore` exclusion to mark line(s) of code as excluded from formatting:
```tsx
// prettier-ignore
const incompleteThemeColorModes: Theme = { colors: { modes: { papaya: { // $ExpectError
// @ts-expect-error
const incompleteThemeColorModes: Theme = { colors: { modes: { papaya: {
```
* `function sum(nums: number[]): number`: Use `ReadonlyArray` if a function does not write to its parameters.
* `interface Foo { new(): Foo; }`:
Expand Down
9 changes: 5 additions & 4 deletions README.pt.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,21 +225,21 @@ const result = twoslash("//")
+ // Lida com o parâmetro options
+ const resultWithOptions = twoslash("//", { version: "3.7" })
+ // Quando o parâmetro está incorreto
+ // $ExpectError
+ // @ts-expect-error
+ const resultWithOptions = twoslash("//", { })
```

Se você está se perguntando por onde começar os testes em seu código, os exemplos no README do módulo são um ótimo lugar para começar.

Você pode [validar suas mudanças](#verificando) executando `npm test` na raiz deste repositório, que leva em consideração os arquivos alterados.

Para afirmar que uma expressão é de um tipo determinado, use `$ExpectType`. Para afirmar que uma expressão causa um erro de compilador, use `$ExpectError`.
Para afirmar que uma expressão é de um tipo determinado, use `$ExpectType`. Para afirmar que uma expressão causa um erro de compilador, use `@ts-expect-error`.

```js
// $ExpectType void
f(1);

// $ExpectError
// @ts-expect-error
f("um");
```

Expand Down Expand Up @@ -280,7 +280,8 @@ Se um arquivo não for testado nem referenciado no `index.d.ts`, adicione-o em u
* Formatação: Use 4 espaços. O Prettier está configurado neste repositório, então você pode executar `npm run prettier -- --write path/to/package/**/*.ts`. [Se estiver usando asserções](https://github.com/SamVerschueren/tsd#assertions), adicione a tag de exclusão `// prettier-ignore` para marcar linhas de código como exclusas da formatação:
```tsx
// prettier-ignore
const incompleteThemeColorModes: Theme = { colors: { modes: { papaya: { // $ExpectError
// @ts-expect-error
const incompleteThemeColorModes: Theme = { colors: { modes: { papaya: {
```
* `function sum(nums: number[]): number`: Use `ReadonlyArray` se a função não adiciona valores a seus parâmetros.
* `interface Foo { new(): Foo; }`:
Expand Down
6 changes: 3 additions & 3 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,21 +220,21 @@ const result = twoslash("//")
+ // Handle options param
+ const resultWithOptions = twoslash("//", { version: "3.7" })
+ // When the param is incorrect
+ // $ExpectError
+ // @ts-expect-error
+ const resultWithOptions = twoslash("//", { })
```
If you're wondering where to start with test code, the examples in the README of the module are a great place to start.
You can [validate your changes](#проверка) with `npm test <package to test>` from the root of this repo, which takes changed files into account.
Чтобы проверить, что выражение имеет заданный тип, используйте `$ExpectType`. Чтобы проверить, что выражение вызывает ошибку компиляции, используйте `$ExpectError`.
Чтобы проверить, что выражение имеет заданный тип, используйте `$ExpectType`. Чтобы проверить, что выражение вызывает ошибку компиляции, используйте `@ts-expect-error`.
```js
// $ExpectType void
f(1);

// $ExpectError
// @ts-expect-error
f('one');
```
Expand Down
9 changes: 5 additions & 4 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,21 +249,21 @@ const result = twoslash("//")
+ // Handle options param
+ const resultWithOptions = twoslash("//", { version: "3.7" })
+ // When the param is incorrect
+ // $ExpectError
+ // @ts-expect-error
+ const resultWithOptions = twoslash("//", { })
```

如果你不知道从何开始,README 中的示例模块是个很好的参考。

你可以在根目录执行 `npm test <package to test>`[validate your changes](#验证) 来验证你的更改。

若要声明的表达式是一个给定类型,请使用 `$ExpectType`. 若要声明的表达式会导致编译错误,请使用 `$ExpectError`.
若要声明的表达式是一个给定类型,请使用 `$ExpectType`. 若要声明的表达式会导致编译错误,请使用 `@ts-expect-error`.

```js
// $ExpectType void
f(1);

// $ExpectError
// @ts-expect-error
f("one");
```

Expand Down Expand Up @@ -305,7 +305,8 @@ Definitely Typed 包的发布者会为在 Definitely Typed 之外没有依赖的
* 格式化:使用 4 个空格。 该仓库已经设置了 prettier,因此你只需要运行 `npm run prettier -- --write path/to/package/**/*.ts`. [使用断言时](https://github.com/SamVerschueren/tsd#assertions),添加 `// prettier-ignore` 将这几行标记为不需要格式化的代码:
```tsx
// prettier-ignore
const incompleteThemeColorModes: Theme = { colors: { modes: { papaya: { // $ExpectError
// @ts-expect-error
const incompleteThemeColorModes: Theme = { colors: { modes: { papaya: {
```
* `function sum(nums: number[]): number`: 如果函数没有写入的参数,请使用 `ReadonlyArray`.
* `interface Foo { new(): Foo; }`:
Expand Down
24 changes: 16 additions & 8 deletions types/abstract-things/abstract-things-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,37 @@ thing.destroyCallback(); // $ExpectType Promise<void>

thing.emitEvent('', ''); // $ExpectType void
thing.emitEvent('', '', { multiple: true }); // $ExpectType void
thing.emitEvent('', '', {}); // $ExpectError
thing.emitEvent('', '', { multiple: '' }); // $ExpectError
// @ts-expect-error
thing.emitEvent('', '', {});
// @ts-expect-error
thing.emitEvent('', '', { multiple: '' });
thing.emitEvent(''); // $ExpectType void
thing.emitEvent(); // $ExpectError
// @ts-expect-error
thing.emitEvent();

thing.on(''); // $ExpectError
// @ts-expect-error
thing.on('');
const stoppable = thing.on('', () => {}); // $ExpectType Stoppable
stoppable.stop(); // $ExpectType void

thing.off(''); // $ExpectError
// @ts-expect-error
thing.off('');
thing.off('', () => {}); // $ExpectType void

thing.onAny(() => {}); // $ExpectType Stoppable
thing.onAny(); // $ExpectError
// @ts-expect-error
thing.onAny();

thing.offAny(() => {}); // $ExpectType void
thing.offAny(); // $ExpectError
// @ts-expect-error
thing.offAny();

thing.debug(); // $ExpectType void

thing.matches(''); // $ExpectType boolean
thing.matches('', ''); // $ExpectType boolean
thing.matches(1); // $ExpectError
// @ts-expect-error
thing.matches(1);
thing.matches(); // $ExpectType boolean

const func: (i: number) => string = i => i.toString();
Expand Down
72 changes: 48 additions & 24 deletions types/accedo__accedo-one/accedo__accedo-one-tests.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,65 @@
import accedoOne = require("@accedo/accedo-one");

accedoOne(); // $ExpectError
// @ts-expect-error
accedoOne();

accedoOne({
appKey: 0, // $ExpectError
// @ts-expect-error
appKey: 0,
});

const accedo = accedoOne({
appKey: 'asf8ggtg0a63189cvbs1278jj354',
});

accedo.getEntries(''); // $ExpectError
accedo.getEntries(0); // $ExpectError
// @ts-expect-error
accedo.getEntries('');
// @ts-expect-error
accedo.getEntries(0);

accedo.getEntryById(); // $ExpectError
accedo.getEntryByAlias(); // $ExpectError
accedo.sendLog(); // $ExpectError
accedo.getMetadataByKey(); // $ExpectError
accedo.getAllApplicationScopeDataByUser(); // $ExpectError
accedo.getAllApplicationGroupScopeDataByUser(); // $ExpectError
accedo.getApplicationScopeDataByUserAndKey(); // $ExpectError
accedo.getApplicationScopeDataByUserAndKey('userName01'); // $ExpectError
// @ts-expect-error
accedo.getEntryById();
// @ts-expect-error
accedo.getEntryByAlias();
// @ts-expect-error
accedo.sendLog();
// @ts-expect-error
accedo.getMetadataByKey();
// @ts-expect-error
accedo.getAllApplicationScopeDataByUser();
// @ts-expect-error
accedo.getAllApplicationGroupScopeDataByUser();
// @ts-expect-error
accedo.getApplicationScopeDataByUserAndKey();
// @ts-expect-error
accedo.getApplicationScopeDataByUserAndKey('userName01');

accedo.getApplicationGroupScopeDataByUserAndKey(); // $ExpectError
accedo.getApplicationGroupScopeDataByUserAndKey('userName01'); // $ExpectError
// @ts-expect-error
accedo.getApplicationGroupScopeDataByUserAndKey();
// @ts-expect-error
accedo.getApplicationGroupScopeDataByUserAndKey('userName01');

accedo.setApplicationScopeUserData(); // $ExpectError
accedo.setApplicationScopeUserData('userName01'); // $ExpectError
// @ts-expect-error
accedo.setApplicationScopeUserData();
// @ts-expect-error
accedo.setApplicationScopeUserData('userName01');

accedo.setApplicationGroupScopeUserData(); // $ExpectError
accedo.setApplicationGroupScopeUserData('userName01'); // $ExpectError
// @ts-expect-error
accedo.setApplicationGroupScopeUserData();
// @ts-expect-error
accedo.setApplicationGroupScopeUserData('userName01');

accedo.setApplicationScopeUserDataByKey(); // $ExpectError
accedo.setApplicationScopeUserDataByKey('userName01'); // $ExpectError
// @ts-expect-error
accedo.setApplicationScopeUserDataByKey();
// @ts-expect-error
accedo.setApplicationScopeUserDataByKey('userName01');

accedo.setApplicationGroupScopeUserDataByKey(); // $ExpectError
accedo.setApplicationGroupScopeUserDataByKey('userName01'); // $ExpectError
accedo.setApplicationGroupScopeUserDataByKey('userName01', 'key02'); // $ExpectError
// @ts-expect-error
accedo.setApplicationGroupScopeUserDataByKey();
// @ts-expect-error
accedo.setApplicationGroupScopeUserDataByKey('userName01');
// @ts-expect-error
accedo.setApplicationGroupScopeUserDataByKey('userName01', 'key02');

accedo.sendLogs(); // $ExpectError
// @ts-expect-error
accedo.sendLogs();
Loading

0 comments on commit 0d30235

Please sign in to comment.