由于TypeScript - TS2304和TS7006,TeamCity构建失败

时间:2017-06-13 11:38:15

标签: c# reactjs typescript teamcity visual-studio-2017

TeamCity Enterprise 2017.1(版本46533)构建失败 - 使用Visual Studio 2017 Pro构建良好。

在TeamCity中构建步骤:

NuGet Installer 
Node.js NPM 
Visual Studio (sln) -> Set for Microsoft Visual Studio 2017

获取这些错误,即使它在我的本地计算机上构建正常。我在"noImplicitAny": true中有.tsconfig,并且不想更改TS7006。为什么我在TeamCity中遇到这些错误而不是在我的本地机器上?

完整的错误日志:https://pastebin.com/Wj0f7pXr

我对TS2304: Build:Cannot find name 'object'.的最后两个错误有所了解。它在日志中说:

[10:36:35] [VsTsc] C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.1\tsc.exe --project "T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\tsconfig.json" --listEmittedFiles

对象已在TypeScript 2.2中添加,但仍未解释其他错误。

https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html

来自构建服务器的TypeScript信息:

C:\Users\COMPANY-BUILD-01>tsc --version
Version 2.3.4

C:\Users\COMPANY-BUILD-01>where tsc
C:\Users\COMPANY-BUILD-01\AppData\Roaming\npm\tsc
C:\Users\COMPANY-BUILD-01\AppData\Roaming\npm\tsc.cmd

编译错误(1):

T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\App.tsx(47, 9): error TS2304: Build:Cannot find name 'fetch'.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\App.tsx(47, 40): error TS7006: Build:Parameter 'response' implicitly has an 'any' type.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\App.tsx(49, 18): error TS7006: Build:Parameter 'aboutModel' implicitly has an 'any' type.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\App.tsx(52, 9): error TS2304: Build:Cannot find name 'fetch'.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\App.tsx(52, 40): error TS7006: Build:Parameter 'response' implicitly has an 'any' type.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\App.tsx(54, 18): error TS7006: Build:Parameter 'factsModel' implicitly has an 'any' type.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\App.tsx(57, 9): error TS2304: Build:Cannot find name 'fetch'.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\App.tsx(57, 43): error TS7006: Build:Parameter 'response' implicitly has an 'any' type.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\App.tsx(59, 18): error TS7006: Build:Parameter 'sidePaneModel' implicitly has an 'any' type.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\App.tsx(62, 9): error TS2304: Build:Cannot find name 'fetch'.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\App.tsx(62, 41): error TS7006: Build:Parameter 'response' implicitly has an 'any' type.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\App.tsx(64, 18): error TS7006: Build:Parameter 'footerModel' implicitly has an 'any' type.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\App.tsx(67, 9): error TS2304: Build:Cannot find name 'fetch'.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\App.tsx(67, 42): error TS7006: Build:Parameter 'response' implicitly has an 'any' type.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\App.tsx(69, 18): error TS7006: Build:Parameter 'optionsModel' implicitly has an 'any' type.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\App.tsx(72, 9): error TS2304: Build:Cannot find name 'fetch'.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\App.tsx(72, 44): error TS7006: Build:Parameter 'response' implicitly has an 'any' type.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\App.tsx(74, 18): error TS7006: Build:Parameter 'contactModel' implicitly has an 'any' type.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\Inventory\index.tsx(24, 9): error TS2304: Build:Cannot find name 'fetch'.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\Inventory\index.tsx(24, 44): error TS7006: Build:Parameter 'response' implicitly has an 'any' type.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\Features\Client\Inventory\index.tsx(26, 18): error TS7006: Build:Parameter 'inventory' implicitly has an 'any' type.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\node_modules\@types\react-router\index.d.ts(82, 23): error TS2304: Build:Cannot find name 'object'.
T:\TeamCity\buildAgent\work\603ae47e37445f5d\Project\Project.Web\node_modules\@types\react-router\index.d.ts(83, 13): error TS2304: Build:Cannot find name 'object'.

1 个答案:

答案 0 :(得分:1)

选中VS Developer命令提示符:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community>tsc --version
Version 2.1.5

然后我尝试从VS 17的TypeScripts主页下载最新版本,但它仍然显示相同的结果。

https://www.typescriptlang.org/index.html#download-links

然后我在开发服务器上启动了Visual Studio - >工具 - >扩展程序和更新... - >产品更新 - >安装了最新的Visual Studio更新。对我而言是Visual Studio Update 15.2 (26430.13)

此版本将TypeScript提升至2.2.3并解决了所有错误。

**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.0.26430.13
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community>tsc -v
Version 2.2.3