如何摆脱<参考路径= QUOT; [英] How to get rid of <reference path="

查看:187
本文介绍了如何摆脱<参考路径= QUOT;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对不起大家,我一直在努力试图理解为什么我需要的

Sorry everyone, I've been struggling trying to understand why I need the

/// <reference path="../typings/browser.d.ts" />

module App {
    angular.module("app", [""]);
}

我用分型,这里是我的 tsconfig

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5",
    "module": "commonjs"
  },
  "files": [

  ],
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}

我每次发现已经有大约几个职位,但不同的答案,不同的场景。

I found already several posts about, but every time a different answer and a different scenario.

我用的Visual Studio 2015年 ReSharper的打字稿1.8.5

在我删除&lt;参考... 标记 ReSharper的说的无法找到名为'角'的但应用程序正常运行。 (可能是因为它找不到智能感知了)

Once I remove <reference... tag ReSharper says "Cannot find name 'angular'" but the application runs normally. (probably because it cannot find the intellisense anymore)

有没有人遇到同样的问题?我缺少的东西吗?

Has anyone faced the same problem? Am I missing something?

推荐答案

tsconfig 文档

如果没有文件属性是present在tsconfig.json,编译器
  默认为包括在所有打字稿(* .TS或* .tsx)文件
  包含的目录和子目录。当一个文件属性
  present,只有指定的文件都包括在内。

If no "files" property is present in a tsconfig.json, the compiler defaults to including all TypeScript (*.ts or *.tsx) files in the containing directory and subdirectories. When a "files" property is present, only the specified files are included.

您使用的是空文件阵列(文件:[] ),这意味着没有文件将被包含在编译器环境。无论你的所有引用添加到文件阵列或删除文件属性完全让编译器包含的所有的上下文中TS文件。

You are using an empty files array ("files": []) which means no files are going to be included in the compiler context. Either add all your references to the files array, or remove the files property completely to allow the compiler to include all TS files in context.

另外,你可以使用导入导出模块的语法来代替。

Alternatively, you can use import and export module syntax instead.

这篇关于如何摆脱&lt;参考路径= QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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