2017-07-20 57 views
0

工作,我从我的gruntfile.js中执行以下任务咕噜:typescriptUsingTsConfig没有在我的项目

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

我复制从任务成功运行的另一个项目此任务。当我运行这个任务,我得到

在这篇文章的底部的错误。打印版本2.4.0是为这个项目安装的。我是

不知道这里缺少什么。

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

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

我更新了我的设置根据反馈到这个线程,但现在收到以下错误:

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. 

回答

0

确定这样的错误正是这说:

'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

声明文件丢失。我不是类似Grunt的TypeScript配置,因为我已经使用了3年左右,但这里是我推荐的。

运行

typings uninstall --save core-js 

然后以防万一运行

npm uninstall --save @types/core-js 

在tsconfig文件,更改

然后或`“compilerOptions”特性"lib"选项,

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

最后如下设置,您可能需要以解决的最后一个错误添加the declaration I suggest in this answer(一对于rxjs /主题)

另外,如果你是好奇,为什么声明核心JS会导致这些问题read my answer to a related question

+0

谢谢Aluan。我提出了你建议的更新,但我现在似乎正在得到一个新的错误。我用“UPDATE”标签下的错误日志更新了我的原始文章 – user8334943

+0

看起来您仍然有'core-js'的类型文件,即'typings/globals/core-js/index.d.ts'正在造成这些错误。删除这个文件并确保它不再在'typings.json'清单中列出。 –

相关问题