如何在 VS2015 的 Typescript 1.5 中强制函数具有 return 声明?

How can I enforce function to have return declarations in Typescript 1.5 on VS2015?

我正在使用 Typescript 1.5 和 Visual Studio 2015。有没有办法强制 typescript 进行检查以确保我的所有函数都声明了 return 类型?

您可以更新您的项目文件以使用 "TypeScriptNoImplicitAny" 然后您需要声明变量的类型,否则您将收到 TS7006 TypeScript 参数错误。

打开你的项目文件并在下面:

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">

添加:

<TypeScriptNoImplicitAny>true</TypeScriptNoImplicitAny>