如何摆脱 <reference path="
How to get rid of <reference path="
对不起大家,我一直在努力理解为什么我需要
/// <reference path="../typings/browser.d.ts" />
module App {
angular.module("app", [""]);
}
我正在使用 typings
,这是我的 tsconfig
:
{
"compilerOptions": {
"experimentalDecorators": true,
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"module": "commonjs"
},
"files": [
],
"exclude": [
"node_modules",
"wwwroot"
]
}
我已经找到好几个帖子了,但每次都有不同的答案和不同的场景。
我用 Visual Studio 2015
和 ReSharper
, TypeScript 1.8.5
我删除 <reference...
标签后 ReSharper
显示 "Cannot find name 'angular'" 但应用程序运行正常。 (可能是因为它找不到智能感知了)
有人遇到过同样的问题吗?我错过了什么吗?
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.
您正在使用空文件数组 ("files": []
),这意味着编译器上下文中不会包含任何文件。要么将所有引用添加到 files
数组,要么完全删除 files
属性 以允许编译器在上下文中包含 all TS 文件。
或者,您可以改用 import
和 export
模块语法。
我使用一个 _reference.ts 文件,其中包含我使用的所有引用 *.d.ts 库。打字稿编译器使用它的信息来导入有关 js 库的定义。使用参考的第二种情况是管理 ts 文件包含到生成的 js 文件中的顺序。换句话说,如果您在文件 B.ts 中添加对 A.ts 的引用,则生成的 js 将首先包含 A.js,然后包含 B。它不是经常需要的,因为 TSC 很聪明,并且按使用的类型排序文件,但有时它很有用,然后你在 B.ts 中动态使用 A.ts 中的一些后缀(不是强类型)。
对不起大家,我一直在努力理解为什么我需要
/// <reference path="../typings/browser.d.ts" />
module App {
angular.module("app", [""]);
}
我正在使用 typings
,这是我的 tsconfig
:
{
"compilerOptions": {
"experimentalDecorators": true,
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"module": "commonjs"
},
"files": [
],
"exclude": [
"node_modules",
"wwwroot"
]
}
我已经找到好几个帖子了,但每次都有不同的答案和不同的场景。
我用 Visual Studio 2015
和 ReSharper
, TypeScript 1.8.5
我删除 <reference...
标签后 ReSharper
显示 "Cannot find name 'angular'" 但应用程序运行正常。 (可能是因为它找不到智能感知了)
有人遇到过同样的问题吗?我错过了什么吗?
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.
您正在使用空文件数组 ("files": []
),这意味着编译器上下文中不会包含任何文件。要么将所有引用添加到 files
数组,要么完全删除 files
属性 以允许编译器在上下文中包含 all TS 文件。
或者,您可以改用 import
和 export
模块语法。
我使用一个 _reference.ts 文件,其中包含我使用的所有引用 *.d.ts 库。打字稿编译器使用它的信息来导入有关 js 库的定义。使用参考的第二种情况是管理 ts 文件包含到生成的 js 文件中的顺序。换句话说,如果您在文件 B.ts 中添加对 A.ts 的引用,则生成的 js 将首先包含 A.js,然后包含 B。它不是经常需要的,因为 TSC 很聪明,并且按使用的类型排序文件,但有时它很有用,然后你在 B.ts 中动态使用 A.ts 中的一些后缀(不是强类型)。