typescript 使用引导程序 4 构建错误“找不到名称‘记录’”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46564979/
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
Build error "Cannot find name 'Record'" with bootstrap 4
提问by Daniel
Today, I decided to migrate my ASP .NET MVC 5 project from bootstrap 3 to bootstrap 4 (the sass version).
今天,我决定将我的 ASP .NET MVC 5 项目从 bootstrap 3 迁移到 bootstrap 4(sass 版本)。
After the migration, I got an error after the compilation of my project.
迁移后,我的项目编译后出现错误。
Error Build:Cannot find name 'Record'.
Error Build:Cannot find name 'undefined'.
错误构建:找不到名称“记录”。
错误构建:找不到名称“未定义”。
How to solve this?
如何解决这个问题?
回答by Daniel
After some research, I found this link to have a better understanding of typescript and visual studio. If you want to improve your skills, you can go to this official pageand have some readings.
经过一番研究,我发现这个链接可以更好地理解打字稿和视觉工作室。如果你想提高你的技能,你可以去这个官方页面并有一些阅读。
The solutionYou just have to update the typescript plugin for Visual studio. You can download the latest version here for visual studio 2015.
解决方案您只需要更新 Visual Studio 的打字稿插件。您可以在此处下载Visual Studio 2015的最新版本。
Enjoy!
享受!
回答by Element808
If, for some reason you are unable to update your Visual Studio with the updated TypeScript .exe file (company/business IT policy, non-admin account, etc...), you can try this solution:
如果由于某种原因您无法使用更新的 TypeScript .exe 文件(公司/企业 IT 策略、非管理员帐户等)更新 Visual Studio,您可以尝试以下解决方案:
- Single-click on the "index.d.ts" file in Visual Studio Solution Explorer.
- Look in the Properties panel, under "Build Action".
- Switch it from "TypeScriptCompile" to "Content".
- 在 Visual Studio 解决方案资源管理器中单击“index.d.ts”文件。
- 查看“属性”面板,在“构建操作”下。
- 将其从“TypeScriptCompile”切换到“Content”。
Now, you'll be able to build your project without these errors.
现在,您将能够在没有这些错误的情况下构建您的项目。
Update 2019I have found another workaround/solution that hasn't had any noticeable effects and still allows me to compile without erroring on index.d.ts. Just comment line 68 in your index.d.ts file as such:
2019 年更新我发现了另一个没有任何明显影响的解决方法/解决方案,并且仍然允许我在index.d.ts上编译而不会出错。只需在 index.d.ts 文件中注释第 68 行,如下所示:
//[name: string]: (BaseModifier & Record<string, any>) | undefined;
回答by Dash
For Visual Studio 2015:
对于 Visual Studio 2015:
I downloaded TypeScript, installed and restarted Visual Studio. While restarting it prompted me the TypeScript my solution uses is older than what is installed(2.9.2) and whether I want to update it to the supported version, I clicked Yes and that fixed the issue.
我下载了TypeScript,安装并重新启动了 Visual Studio。重新启动时,它提示我我的解决方案使用的 TypeScript 比安装的版本(2.9.2)旧,以及我是否要将其更新到受支持的版本,我单击“是”并解决了该问题。
My guess is TypeScript 2.9.2 is for VS 2017 maybe.
我的猜测是 TypeScript 2.9.2 可能适用于 VS 2017。
回答by Jeffery Hill
I uninstalled jpopper.cs and went to the Web.config file and added these lines of code
我卸载了 jpopper.cs 并转到了 Web.config 文件并添加了这些代码行
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
to deal with that validation error.
处理该验证错误。
回答by kuldeep chopra
- open your project in visual studio 2017 and it will ask you to upgrade the typescript just press upgrade
OR
- 在 Visual Studio 2017 中打开您的项目,它会要求您升级打字稿,只需按升级
或者
Upgrade your Typescript version
升级你的 Typescript 版本
回答by Saurin Vala
Out of the box, for me it has been fixed by update VS 17 to latest version!!
开箱即用,对我来说,它已通过将 VS 17 更新到最新版本来修复!!