收到错误 - 找不到名称'角' [英] Getting Error - Cannot find name 'angular'

查看:143
本文介绍了收到错误 - 找不到名称'角'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始写使用打字稿AngularJS应用程序。我有这个简单的模块的命令:

I'm starting writing AngularJS app using TypeScript. I have this simple module command:

(() => {
    angular
        .module('app', []);
})();

当我运行 TSC app.ts ,我得到这个: app.ts(2,5):错误TS2304:找不到名称'角。

When I run tsc app.ts, I got this: app.ts(2,5): error TS2304: Cannot find name 'angular'.

我需要包括的东西 app.ts ,使 TSC 了解

Do I need to include something to app.ts to make tsc understand the angular?

问候,

推荐答案

您可以简单地告诉编译器停止告诉它令人担忧的是:你知道所有关于角:

You could simplistically tell the compiler to stop worrying by telling it that "you know all about angular":

declare var angular: any;

要得到所有的好工具和类型检查,你需要在角类型定义所以编译器知道什么是可用的。

To get all the good tooling and type checking, you need to pull in the Angular type definition so the compiler knows what is available.

该类型定义通过的NuGet可如果你正在使用Visual Studio或其他各种方式为您最喜爱的IDE。

The type definitions are available via NuGet if you are using Visual Studio or various other methods for your favourite IDE.

这篇关于收到错误 - 找不到名称'角'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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