编入wwwroot的Typescript为我提供了“重复标识符”错误 [英] Typescript compiled into wwwroot gives me "Duplicate identifier" error

查看:211
本文介绍了编入wwwroot的Typescript为我提供了“重复标识符”错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定我是否错误地构建了我的项目,或者我错过了一个设置,但是我在visual studio 2015中遇到了一个重复标识符错误的问题。



我在我的ASP.NET 5项目中拥有所有的打字稿文件,并且我有一个将它们编译为javascript的咕噜任务,并将它们放入wwwroot文件夹中的脚本文件夹内。如果我理解正确,这就是将要部署的文件的位置。



我遇到的问题是,当我运行grunt任务并获取输出文件时正确地说,visual studio开始警告我在我的打字稿文件中有重复的标识符。我会认为我可以告诉VS在某处忽略wwwroot文件夹,但我似乎无法找到任何有关此信息。



任何人都有这之前,还是我得到了棒如何我应该接近结构的错误结局?

解决方案


visual studio在我的脚本文件中开始警告我有重复的标识符


如果您拥有 2 > TypeScript 文件 declare 相同的东西。正如你所知道的编译输出 JavaScript ,所以这不是造成这个错误的原因。修正:删除重复的TypeScript。



PS



lockquote

我有一个grunt任务,将它们编译为javascript,并将它们放入wwwroot文件夹中的脚本文件夹中。

不是源代码的错误。但是我会使用glob lib / ** / * .js 来在VS项目中包含 *。js 因为 wwwroot 确实适用于特定的IIS安装,并且在发布 Web应用程序时不可移植。

I'm not sure if I've structured my project incorrectly or theres a setting I'm missing but I'm having a bit of an issue in visual studio 2015 with a "Duplicate identifier" error.

I have all of my typescript files in my ASP.NET 5 project and I have a grunt task that compiles them into javascript and places them inside of a scripts folder in the wwwroot folder. If I understand it correctly this is where the files that will be deployed should be.

The issue I have though is that when I run the grunt task and get the files outputted correctly, visual studio starts warning me inside my typescript files that I have duplicate identifiers. I would have thought that I'd be able to tell VS to ignore the wwwroot folder somewhere, but I can't seem to find any information on this.

Anyone had this before, or have I got the wrong end of the stick with how I should approach the structure?

解决方案

visual studio starts warning me inside my typescript files that I have duplicate identifiers

This will only happen (baring any plugin like resharper) if you have two TypeScript files declareing the same stuff. As you know compile outputs JavaScript so that is not the cause of this error. Fix: Remove the duplicate TypeScript.

PS

I have a grunt task that compiles them into javascript and places them inside of a scripts folder in the wwwroot folder

Not the source of your error. But I would include the *.js files in the VS project using a glob lib/**/*.js as wwwroot is really for a particular IIS installation and not portable when you publish web apps.

这篇关于编入wwwroot的Typescript为我提供了“重复标识符”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆