无法找到' ng'在模块中... - 断开智能感知?

时间:2015-04-22 21:56:50

标签: javascript angularjs typescript typescript1.4

当尝试引用外部模块时,Intellisense会发出错误...

Could not find symbol 'ng' in global module

或..

Could not find symbol 'ng' in module 'App' // my main module

..即使我正确引用了打字稿定义(使用了YetTyped):

_references.ts

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

declare var angular: ng.IAngularStatic; // unable to find in global module

SomeDirective.ts

/// <reference path="_references.ts" />

module App {
    export class SomeDirective implements ng.IDirective // unable to find in module 'App'
}

有趣的是,使用grunt-typescript编译* .ts文件工作正常,应用程序运行没有任何问题。

2 个答案:

答案 0 :(得分:2)

您已在代码库中的某处“声明模块化”。请将其更改为“声明模块角度”

详细信息:https://github.com/borisyankov/DefinitelyTyped/pull/3851#issue-60749247

<强>更新

我的意思是搜索SELECT sum(i.invoice_net) As Sales, (SELECT sum(p.total_order) FROM purchase p WHERE p.projectID = i.projectID) As Purchases FROM invoice i WHERE i.projectID=7 。应该有结果(我怀疑你的代码库不是这种情况)。

注意:declare module ng现在angular.d.ts不是declare module angular

https://github.com/borisyankov/DefinitelyTyped/blob/master/angularjs/angular.d.ts#L26

答案 1 :(得分:0)

我有完全相同的问题。我替换了打字&#34;声明命名空间angular&#34; to&#34;声明模块角度&#34;现在一切都很棒!

来自这里:https://github.com/DefinitelyTyped/DefinitelyTyped

我已将此文件包含在angular.d.ts(///)