Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在不使用任何引用的情况下编译TypeScript_Javascript_Angularjs_Typescript_Tsd - Fatal编程技术网

Javascript 如何在不使用任何引用的情况下编译TypeScript

Javascript 如何在不使用任何引用的情况下编译TypeScript,javascript,angularjs,typescript,tsd,Javascript,Angularjs,Typescript,Tsd,如果我误解了,请原谅,但我认为如果我在项目根目录中使用了tsconfig.json文件,那么我就不再需要使用任何//标记来编译代码。我错了吗 例如,我正在使用AngularJS。我的App.ts文件如下所示: import SomeModule from './whatever/SomeModule'; angular.module('foo', [SomeModule.name]).run(...); { "compileOnSave": false, "compilerO

如果我误解了,请原谅,但我认为如果我在项目根目录中使用了
tsconfig.json
文件,那么我就不再需要使用任何
//
标记来编译代码。我错了吗

例如,我正在使用AngularJS。我的
App.ts
文件如下所示:

import SomeModule from './whatever/SomeModule';

angular.module('foo', [SomeModule.name]).run(...);
{
    "compileOnSave": false,
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs"
    },
    "filesGlob": [
        "./www/**/*.ts",
        "./typings/**/*.ts"
    ],
    "files": [
        /* a bunch of files omitted for brevity*/
        "./typings/angularjs/angular.d.ts"
    ],
}
我的
tsconfig.json
文件(部分)如下所示:

import SomeModule from './whatever/SomeModule';

angular.module('foo', [SomeModule.name]).run(...);
{
    "compileOnSave": false,
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs"
    },
    "filesGlob": [
        "./www/**/*.ts",
        "./typings/**/*.ts"
    ],
    "files": [
        /* a bunch of files omitted for brevity*/
        "./typings/angularjs/angular.d.ts"
    ],
}
请注意,我在文件数组中列出了角度定义文件的路径。还要注意,我将
compileOnSave
选项设置为false。最后,我想使用Browserify来编译和捆绑所有代码。但现在我只想看看我是否能用
tsc
编译它


但是,当我运行
tsc App.ts
时,我会收到一个错误,上面写着“找不到名称'angular'。“在编译代码时,如何使TypeScript编译使用
angular.d.ts
文件?

运行
tsc App.ts
将无法工作,因为指定了一个文件。按照文档中的说明进行操作:

使用tsconfig.json

  • 通过在没有输入文件的情况下调用
    tsc
    ,在这种情况下,编译器将从当前目录开始搜索
    tsconfig.json
    文件,并继续搜索父目录链
  • 通过调用
    tsc
    而不使用输入文件和-project(或-p)命令行选项,该选项指定包含
    tsconfig.json
    文件的目录的路径
在命令行上指定输入文件时,将忽略tsconfig.json文件


阅读文档-但愿我想到了这一点!:)