Definitelytyped: Error TS2693: 'Map' only refers to a type, but is being used as a value here.

Created on 20 Jul 2017  路  10Comments  路  Source: DefinitelyTyped/DefinitelyTyped

I have following
package.json:
{
"name": "a2-starter",
"version": "0.1.0",
"dependencies": {
"angular/common": "~2.4.0",
"angular/compiler": "~2.4.0",
"angular/core": "~2.4.0",
"angular/forms": "~2.4.0",
"angular/http": "~2.4.0",
"ngular/platform-browser": "~2.4.0",
"angular/platform-browser-dynamic": "~2.4.0",
"angular/router": "~3.4.0",
"reflect-metadata": "0.1.3",
"core-js": "2.4.0",
"rxjs": "5.0.1",
"zone.js": "^0.7.4"
},
"devDependencies": {
"typescript": "^2.4.2",
"typings": "^1.5.0"
}
}

I have also installed core-js with following command:
typings install --gloabl --save dt~core-js
and its installed successfully.

But after running command:
tsc -p src --outDir dist
Its throwing following errors
C:Users358291Desktopa2-starter>tsc --outDir dist
node_modules/@angular/core/src/facade/lang.d.ts(12,17): error TS2693: 'Map' only
refers to a type, but is being used as a value here.
node_modules/@angular/core/src/facade/lang.d.ts(13,17): error TS2693: 'Set' only
refers to a type, but is being used as a value here.
node_modules/rxjs/Observable.d.ts(68,60): error TS2693: 'Promise' only refers to
a type, but is being used as a value here.
node_modules/rxjs/Subject.d.ts(16,22): error TS2415: Class 'Subject' incorrec
tly extends base class 'Observable'. ....

Please any suggestion

Most helpful comment

@krushanu do you have your libs setup correctly? inside of your tsconfig.json -> compilerOptions you should have a property

 "lib": [
      "es2016"
    ]

That should provide the definition for Map and other ES6 definitions

All 10 comments

I had same problem when try to use npm/@types instead of typings. I return to old way of managing dt files. Try to use this file https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/3c56e866d6edd234416a92c3d35c15ccd7fe6b72/core-js/index.d.ts

Managing typescript declaration files is really horrible.

I get the same error TS2693. I'm using this dev dependency:

    "@types/core-js": "0.9.43",

Any idea for a solution in sight?

@NicoleRauch So I was having the same issue and found that this lib npm install --save @types/es6-shim fixed it. I am not sure why the tsconfig lib es6 and/or es5 does not create the definitions for this tho

@dfenstermaker I am getting the same issue. But this npm install --save @types/es6-shim library did not solve my problem.

@krushanu do you have your libs setup correctly? inside of your tsconfig.json -> compilerOptions you should have a property

 "lib": [
      "es2016"
    ]

That should provide the definition for Map and other ES6 definitions

Sorry, didn't solve the problem, for me!

@dfenstermaker Neither for me

My typescript version is 2.8.4

Passing explicitly the _lib_ argument from the CLI worked for me:
npx tsc electron.ts --lib es2016,dom (node: 8.11.3, ts: 2.7.2)

For clarification, this set of typings is located specifically in the "es2016", "es2015", or "es2015.collections" libraries. If you are doing any funny stuff with your compilation target you will likely want to add one of those libs to your --lib or tsconfig.

https://www.typescriptlang.org/docs/handbook/compiler-options.html

@itsjustdanger There is a typo above
"es2015.collections" _should read_ "es2015.collection"

Was this page helpful?
0 / 5 - 0 ratings