简体   繁体   English

在Visual Studio 2015中设置打字稿

[英]Setting up Typescript in Visual Studio 2015

I am working on a project that utilizes AngularJS / Gulp and we are attempting to migrate to Angular. 我正在开发一个利用AngularJS / Gulp的项目,我们正尝试迁移到Angular。

Can someone inform me on how to properly allow the addition of .ts files in a project using VS 2015? 有人可以告知我如何正确使用VS 2015在项目中添加.ts文件吗? Steps performed so far: 到目前为止执行的步骤:

- Installed Microsoft.TypeScript.Compiler v2.9.1 (stable) via Nuget packet manager
- npm install @angular/core
- npm install @angular/upgrade 
- npm install @angular/platform-browser
- npm install @angular/platform-browser-dynamic

When I add a .ts file to my project I receive 2500 errors. 当我向项目添加.ts文件时,我收到2500错误。 Some of which are shown below: 其中一些如下所示:

Error Build:'(' expected. app\node_modules\@angular\core\src\application_init.d.ts  17  
Error Build:'=' expected. \app\node_modules\@angular\core\src\application_init.d.ts 18      
Error Build:';' expected. \app\node_modules\@angular\core\src\application_ref.d.ts  185

What am I missing when adding a typescript file to my project that it causes so many issues? 将打字稿文件添加到项目中会导致很多问题时,我缺少什么?

EDIT: 编辑:

I included a tsconfig.json file (below) and my error # reduced to 127. Am I missing additional config options? 我包含一个tsconfig.json文件(如下),并且错误号降至127。我是否缺少其他配置选项?

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "allowJs": true,
    "noImplicitAny": true,
    "target": "es6",
    "lib": ["es2016", "dom"]
}

Solution: The problem was I had a global and local install of typescript. 解决方案:问题是我在全球和本地安装了打字稿。 I needed to run "npm uninstall -g typescript" and "npm uninstall typescript". 我需要运行“ npm卸载-g打字稿”和“ npm卸载打字稿”。 From there do a fresh global install "npm install -g typescript" 从那里进行全新的全局安装“ npm install -g typescript”

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

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