typescript 成功构建,但打字稿键入文件中存在许多错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28086084/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 02:57:34  来源:igfitidea点击:

Successful build with many errors in typescript typing files

visual-studio-2013typescript

提问by papadi

I have a problem with Visual Studio 2013 generating too many errors when building a web application with typescript definition files. For example consider the following scenario:

我在使用打字稿定义文件构建 Web 应用程序时遇到了 Visual Studio 2013 生成太多错误的问题。例如,考虑以下场景:

  1. Start a new Empty Web Application
  2. Right click on project and select Manage Nuget Packages
  3. Add jquery and jquery typings (the typings I downloaded are a couple of days old)
  4. Build the project
  5. Project builds successfully with more than 100 errors (errors, not warnings), all in jquery.d.ts, like the following:
    • ',' expected.
    • '=' expected.
    • Identifier expected.
  1. 启动一个新的空 Web 应用程序
  2. 右键单击项目并选择管理 Nuget 包
  3. 添加 jquery 和 jquery 类型(我下载的类型是几天前的)
  4. 构建项目
  5. 项目构建成功,有 100 多个错误(错误,不是警告),都在 jquery.d.ts 中,如下所示:
    • ',' 预期的。
    • '=' 预期。
    • 标识符预期。

I get similar results when I do the same with angularjs instead of jquery.

当我用 angularjs 而不是 jquery 做同样的事情时,我得到了类似的结果。

Any ideas?

有任何想法吗?

回答by Fenton

The most likely reason for this is that you are using an older version of TypeScript than the definition author.

最可能的原因是您使用的 TypeScript 版本比定义作者旧。

The language is moving swiftly and some of the features in version 1.4 are particularly useful in definition files, so it is likely that you will need to upgrade to 1.4 so that your machine can understand these new features.

该语言发展迅速,1.4 版中的某些功能在定义文件中特别有用,因此您可能需要升级到 1.4 版,以便您的机器能够理解这些新功能。

Download version 1.4 here.

在此处下载 1.4 版

回答by JayKan

I was having a similar issues like this but I was able to resolve the jQuery issues by downgrading my DefinitelyTyped version of "1.0.1" instead of "1.4.1". Also I'm currently running on Mac and hopefully this can help users who are experiencing issues on Mac.

我遇到了类似的问题,但我能够通过将我的绝对类型版本“1.0.1”而不是“1.4.1”降级来解决 jQuery 问题。此外,我目前正在 Mac 上运行,希望这可以帮助在 Mac 上遇到问题的用户。