0

I'm executing the following grunt task from within my gruntfile.js:

    'typescriptUsingTsConfig': {
        'basic': {
            'options': {
                'rootDir': './ng2'
            }
        }
    }

I copied this task from another project where the task runs successfully. When I run this task I get

the error at the bottom of this post. Version 2.4.0 of typescript is installed for this project. I'm

not sure what's missing here.

====================================================================================================

C:\CODE\Test\src\Test.Website> cmd.exe /c grunt -b "C:\CODE\Test\src\Test.Website" --gruntfile "C:

\CODE\Test\src\Test.Website\Gruntfile.js" typescriptUsingTsConfig --color
Running "typescriptUsingTsConfig:basic" (typescriptUsingTsConfig) task
Running C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External\Node.exe C:

\CODE\Test\src\Test.Website\node_modules\typescript\bin\tsc --project ./ng2
Warning: ng2/app.module.ts(1,21): error TS6053: File 

'C:/CODE/Test/src/Test.Website/typings/globals/core-js/index.d.ts' not found.
ng2/services/user.service.ts(37,16): error TS2693: 'Promise' only refers to a type, but is being used 

as a value here.
node_modules/@angular/common/src/directives/ng_class.d.ts(48,34): error TS2304: Cannot find name 

'Set'.
node_modules/@angular/compiler/src/aot/compiler.d.ts(56,32): error TS2304: Cannot find name 'Map'.
node_modules/@angular/compiler/src/compile_metadata.d.ts(369,20): error TS2304: Cannot find name 

'Set'.
node_modules/@angular/compiler/src/compile_metadata.d.ts(371,28): error TS2304: Cannot find name 

'Set'.
node_modules/@angular/compiler/src/compile_metadata.d.ts(373,15): error TS2304: Cannot find name 

'Set'.
node_modules/@angular/compiler/src/compile_metadata.d.ts(375,23): error TS2304: Cannot find name 

'Set'.
node_modules/@angular/compiler/src/compile_metadata.d.ts(377,17): error TS2304: Cannot find name 

'Set'.
node_modules/@angular/compiler/src/compile_metadata.d.ts(379,25): error TS2304: Cannot find name 

'Set'.
node_modules/@angular/compiler/src/output/output_ast.d.ts(458,63): error TS2304: Cannot find name 

'Set'.
node_modules/@angular/core/src/change_detection/differs/default_iterable_differ.d.ts(28,32): error 

TS2304: Cannot find name 'Iterable'.
node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(24,16): error 

TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(32,16): error 

TS2304: Cannot find name 'Map'.
node_modules/@angular/core/src/change_detection/differs/iterable_differs.d.ts(15,48): error TS2304: 

Cannot find name 'Iterable'.
node_modules/@angular/core/src/change_detection/differs/keyvalue_differs.d.ts(23,18): error TS2304: 

Cannot find name 'Map'.
node_modules/@angular/core/src/di/reflective_provider.d.ts(87,123): error TS2304: Cannot find name 

'Map'.
node_modules/@angular/core/src/di/reflective_provider.d.ts(87,165): error TS2304: Cannot find name 

'Map'.
node_modules/@angular/http/src/headers.d.ts(52,71): error TS2304: Cannot find name 'Map'.
node_modules/@angular/http/src/url_search_params.d.ts(46,16): error TS2304: Cannot find name 'Map'.
node_modules/@angular/platform-browser/src/browser/browser_adapter.d.ts(79,33): error TS2304: Cannot 

find name 'Map'.
node_modules/@angular/platform-browser/src/dom/dom_adapter.d.ts(97,42): error TS2304: Cannot find name 

'Map'.
node_modules/@angular/platform-browser/src/dom/shared_styles_host.d.ts(11,30): error TS2304: Cannot 

find name 'Set'.
node_modules/@angular/platform-browser/src/dom/shared_styles_host.d.ts(22,30): error TS2304: Cannot 

find name 'Set'.
node_modules/@angular/router/src/router_outlet_context.d.ts(42,28): error TS2304: Cannot find name 

'Map'.
node_modules/@angular/router/src/router_outlet_context.d.ts(43,34): error TS2304: Cannot find name 

'Map'.
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<T>' incorrectly extends base class 

'Observable<T>'.
  Types of property 'lift' are incompatible.
    Type '<R>(operator: Operator<T, R>) => Observable<T>' is not assignable to type '<R>(operator: 

Operator<T, R>) => Observable<R>'.
      Type 'Observable<T>' is not assignable to type 'Observable<R>'.
        Type 'T' is not assignable to type 'R'.
node_modules/rxjs/operator/toPromise.d.ts(3,79): error TS2693: 'Promise' only refers to a type, but is 

being used as a value here. Use --force to continue.
Aborted due to warnings.
Process terminated with code 1.

UPDATE

I updated my setup based on feedback to this thread but now getting the following error:

C:\CODE\Test.Web.Benport\src\Test.Web.Website> cmd.exe /c grunt -b "C:\CODE\Test.Web.Benport\src\Test.Web.Website" --gruntfile "C:\CODE\Test.Web.Benport\src\Test.Web.Website\Gruntfile.js" typescriptUsingTsConfig --color
Running "typescriptUsingTsConfig:basic" (typescriptUsingTsConfig) task
Running C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External\Node.exe C:\CODE\Test.Web.Benport\src\Test.Web.Website\node_modules\typescript\bin\tsc --project ./ng2
Warning: node_modules/typescript/lib/lib.es2015.collection.d.ts(45,11): error TS2428: All declarations of 'WeakMap' must have identical type parameters.
node_modules/typescript/lib/lib.es2015.core.d.ts(21,14): error TS2300: Duplicate identifier 'PropertyKey'.
node_modules/typescript/lib/lib.es2015.iterable.d.ts(124,11): error TS2428: All declarations of 'WeakMap' must have identical type parameters.
node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts(133,11): error TS2428: All declarations of 'WeakMap' must have identical type parameters.
typings/globals/core-js/index.d.ts(3,14): error TS2300: Duplicate identifier 'PropertyKey'.
typings/globals/core-js/index.d.ts(67,5): error TS2687: All declarations of 'name' must have identical modifiers.
typings/globals/core-js/index.d.ts(127,5): error TS2403: Subsequent variable declarations must have the same type.  Variable '[Symbol.unscopables]' must be of type '{ copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: ...', but here has type 'any'.
typings/globals/core-js/index.d.ts(244,5): error TS2687: All declarations of 'flags' must have identical modifiers.
typings/globals/core-js/index.d.ts(258,5): error TS2687: All declarations of 'EPSILON' must have identical modifiers.
typings/globals/core-js/index.d.ts(293,5): error TS2687: All declarations of 'MAX_SAFE_INTEGER' must have identical modifiers.
typings/globals/core-js/index.d.ts(300,5): error TS2687: All declarations of 'MIN_SAFE_INTEGER' must have identical modifiers.
typings/globals/core-js/index.d.ts(439,5): error TS2403: Subsequent variable declarations must have the same type.  Variable '[Symbol.toStringTag]' must be of type '"Symbol"', but here has type 'string'.
typings/globals/core-js/index.d.ts(439,5): error TS2687: All declarations of '[Symbol.toStringTag]' must have identical modifiers.
typings/globals/core-js/index.d.ts(446,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
typings/globals/core-js/index.d.ts(474,5): error TS2687: All declarations of 'hasInstance' must have identical modifiers.
typings/globals/core-js/index.d.ts(480,5): error TS2687: All declarations of 'isConcatSpreadable' must have identical modifiers.
typings/globals/core-js/index.d.ts(486,5): error TS2687: All declarations of 'iterator' must have identical modifiers.
typings/globals/core-js/index.d.ts(492,5): error TS2687: All declarations of 'match' must have identical modifiers.
typings/globals/core-js/index.d.ts(498,5): error TS2687: All declarations of 'replace' must have identical modifiers.
typings/globals/core-js/index.d.ts(504,5): error TS2687: All declarations of 'search' must have identical modifiers.
typings/globals/core-js/index.d.ts(510,5): error TS2687: All declarations of 'species' must have identical modifiers.
typings/globals/core-js/index.d.ts(516,5): error TS2687: All declarations of 'split' must have identical modifiers.
typings/globals/core-js/index.d.ts(522,5): error TS2687: All declarations of 'toPrimitive' must have identical modifiers.
typings/globals/core-js/index.d.ts(528,5): error TS2687: All declarations of 'toStringTag' must have identical modifiers.
typings/globals/core-js/index.d.ts(534,5): error TS2687: All declarations of 'unscopables' must have identical modifiers.
typings/globals/core-js/index.d.ts(591,5): error TS2403: Subsequent variable declarations must have the same type.  Variable '[Symbol.toStringTag]' must be of type '"Math"', but here has type 'string'.
typings/globals/core-js/index.d.ts(591,5): error TS2687: All declarations of '[Symbol.toStringTag]' must have identical modifiers.
typings/globals/core-js/index.d.ts(595,5): error TS2403: Subsequent variable declarations must have the same type.  Variable '[Symbol.toStringTag]' must be of type '"JSON"', but here has type 'string'.
typings/globals/core-js/index.d.ts(595,5): error TS2687: All declarations of '[Symbol.toStringTag]' must have identical modifiers.
typings/globals/core-js/index.d.ts(610,5): error TS2687: All declarations of 'size' must have identical modifiers.
typings/globals/core-js/index.d.ts(616,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
typings/globals/core-js/index.d.ts(627,5): error TS2687: All declarations of 'size' must have identical modifiers.
typings/globals/core-js/index.d.ts(633,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
typings/globals/core-js/index.d.ts(638,11): error TS2428: All declarations of 'WeakMap' must have identical type parameters.
typings/globals/core-js/index.d.ts(646,27): error TS2344: Type 'K' does not satisfy the constraint 'object'.
typings/globals/core-js/index.d.ts(647,53): error TS2344: Type 'K' does not satisfy the constraint 'object'.
typings/globals/core-js/index.d.ts(648,5): error TS2403: Subsequent variable declarations must have the same type.  Variable 'prototype' must be of type 'WeakMap<object, any>', but here has type 'WeakMap<any, any>'.
typings/globals/core-js/index.d.ts(648,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
typings/globals/core-js/index.d.ts(662,5): error TS2403: Subsequent variable declarations must have the same type.  Variable 'prototype' must be of type 'WeakSet<object>', but here has type 'WeakSet<any>'.
typings/globals/core-js/index.d.ts(662,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
typings/globals/core-js/index.d.ts(674,5): error TS2687: All declarations of 'value' must have identical modifiers.
typings/globals/core-js/index.d.ts(786,5): error TS2687: All declarations of 'prototype' must have identical modifiers. Use --force to continue.
Aborted due to warnings.
Process terminated with code 1.
user8334943
  • 1,467
  • 3
  • 11
  • 21

1 Answers1

0

OK so the error is exactly what it says:

'C:/CODE/Test/src/Test.Website/typings/globals/core-js/index.d.ts' not found. ng2/services/user.service.ts(37,16): error TS2693: 'Promise' only refers to a type, but is being used

A declaration file is missing. I am not faimilar Grunt's TypeScript configuration, as I have not used it for around 3 years, but here is what I recommend regardless.

Run

typings uninstall --save core-js

Then run

npm uninstall --save @types/core-js

just in case.

Then in your tsconfig file, change or set the "lib" option of the `"compilerOptions" property as follows

{
  "compilerOptions": {
    "lib": ["dom", "es2015"],
    // whatever else you had previously
  }
}

Finally, you may need to add the declaration I suggest in this answer in order to resolve the last error (the one for rxjs/Subject)

Also, if you are curious as to why the declarations for core-js cause these issues read my answer to a related question

Aluan Haddad
  • 29,886
  • 8
  • 72
  • 84
  • Thanks Aluan. I made the updates you suggested but I now appear to be getting a new error. I updated my original post with the error log under the "UPDATE" label – user8334943 Jul 20 '17 at 16:52
  • Looks like you still have a typings file for `core-js`, namely `typings/globals/core-js/index.d.ts` that is what is causing these errors. Delete this file and make sure it is not listed in your `typings.json` manifest any longer. – Aluan Haddad Jul 20 '17 at 16:54