TS2304

error TS2304: Cannot find name ‘Promise’

Bad Code ❌

1
2
3
4
5
6
7
8
9
// ...

public load_prekey(prekey_id: number): Promise<Proteus.keys.PreKey> {
return new Promise((resolve) => {
resolve(42);
});
}

// ...

Fixed Code ✔️

Install es6-promise type definitions with the typings tool.

1
typings install dt~es6-promise --global --save

Adding the following line to the beginning of every file using definitions from es6-promise.

1
2
3
4
5
6
7
8
9
10
11
/// <reference path='es6-promise.d.ts' />

...

public load_prekey(prekey_id: number): Promise<Proteus.keys.PreKey> {
return new Promise((resolve) => {
resolve(42);
});
}

...

TS2304

error TS2304: Cannot find name ‘Promise’

Bad Code ❌

1
const UUID = require('uuidjs');

Fixed Code ✔️

1
npm install @types/node --save-dev