简体   繁体   English

Angular 2打字稿参考路径

[英]Angular 2 typescript reference path

I've been trying to set up a working environment for angular 2 projects using Typescript and Visual Studio 2013. So far I've been following this tutorial link - but I'm still getting the common error that the experimental decorators are showing an error. 我一直在尝试使用Typescript和Visual Studio 2013为angular 2项目设置工作环境。到目前为止,我一直在关注本教程链接 -但是我仍然遇到常见错误,即实验装饰器显示错误。 I'm at the step in the tutorial where I need to write these lines 我在本教程中需要写这些行的步骤

/// <reference path="node_modules/angular2/bundles/typings/es6-shim/es6-shim.d.ts" />
/// <reference path="node_modules/angular2/bundles/typings/angular2/angular2.d.ts" />

In the app.ts file. 在app.ts文件中。 Maybe this tutorial was written a while ago because these paths don't match the folder structure I have in my node_modules folder and I can't seem to find the matching files. 也许本教程是前一段时间编写的,因为这些路径与我的node_modules文件夹中的文件夹结构不匹配,并且我似乎找不到匹配的文件。 My question is, have these files changed names? 我的问题是,这些文件是否已更改名称? Is it possible to just give the broader file path and have VS look the files up or something? 是否可以给出更宽的文件路径,让VS查找文件或其他内容? How do I fix this? 我该如何解决?

Thank you so much for your patience... I just can't get wait to get through this annoying environment setup and get to actual coding. 非常感谢您的耐心等待……我迫不及待地想要完成这个烦人的环境设置并进行实际编码。

You have to use a relative to your current script path. 您必须使用相对于当前脚本路径的相对路径。 Try something like this: 尝试这样的事情:
/// <reference path="../node_modules/angular2/bundles/typings/es6-shim/es6-shim.d.ts" />
/// <reference path="../node_modules/angular2/bundles/typings/angular2/angular2.d.ts" />
Of course that depends on the location of the script in which you call it. 当然,这取决于您在其中调用脚本的位置。 In my example the script will be located in a directory on the same level as the node_modules directory. 在我的示例中,脚本将位于与node_modules目录相同级别的目录中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM