CaitlinG
CaitlinG

Reputation: 2015

Difficulty in compiling TypeScript

I downloaded the most recent version of TypeScript and NodeJS, obtained a small example in TypeScript, and attempted to compile using both Node terminal and a Windows 10 command line. Please see below:

The sample program I'm using is:

let greeting:string = "Hello!";
console.log(greeting);
C:\Users\CaitlinG>tsc greet.ts
node_modules/@types/mongodb/index.d.ts:482:22 - error TS2304: Cannot find name 'PromiseConstructor'.

482     promiseLibrary?: PromiseConstructor;
                         ~~~~~~~~~~~~~~~~~~

node_modules/@types/mongoose/index.d.ts:1706:26 - error TS2507: Type 'MapConstructor' is not a constructor function type.

1706     class Map<V> extends global.Map<string, V> {
                              ~~~~~~~~~~

node_modules/@types/mongoose/index.d.ts:1716:37 - error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the `l
ib` compiler option to es2015 or later.

1716   interface GlobalMap<K, V> extends Map<K, V> {}
                                         ~~~

node_modules/@types/webgl2/index.d.ts:582:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'WebGL2RenderingConte
xt' must be of type '{ new (): WebGL2RenderingContext; prototype: WebGL2RenderingContext; readonly ACTIVE_ATTRIBUTES: number; readonly ACTIVE_TEXTURE:
 number; ... 556 more ...; readonly WAIT_FAILED: number; }', but here has type '{ new (): WebGL2RenderingContext; prototype: WebGL2RenderingContext; r
eadonly ACTIVE_ATTRIBUTES: number; readonly ACTIVE_TEXTURE: number; ... 557 more ...; readonly MAX_CLIENT_WAIT_TIMEOUT_WEBGL: number; }'.

582 declare var WebGL2RenderingContext: {
                ~~~~~~~~~~~~~~~~~~~~~~

  AppData/Roaming/npm/node_modules/typescript/lib/lib.dom.d.ts:16316:13
    16316 declare var WebGL2RenderingContext: {
                      ~~~~~~~~~~~~~~~~~~~~~~
    'WebGL2RenderingContext' was also declared here.

I don't understand how to resolve these issues.

Upvotes: 0

Views: 378

Answers (1)

Shijil Narayanan
Shijil Narayanan

Reputation: 1019

Try adding the following in your tsconfig.

"compilerOptions": {
    "lib": ["dom", "es6"]
}

Upvotes: 1

Related Questions