模块" ng"在vs代码中没有导出的成员

时间:2015-12-20 12:27:34

标签: typescript visual-studio-code definitelytyped tsd

我在visual studio code中的所有输入中收到错误消息Module "ng" has no exported member

enter image description here

enter image description here

我的打字工作100%,直到我添加了angular-ui-router。我不确定这是不是问题,但我在添加之后才注意到它。

在我的.d.ts文件中,我在angular本身上遇到了特定错误。

enter image description here

我的tsd.json看起来像这样

{
  "version": "v4",
  "repo": "borisyankov/DefinitelyTyped",
  "ref": "master",
  "path": "typings",
  "bundle": "typings/tsd.d.ts",
  "installed": {
    "angular-material/angular-material.d.ts": {
      "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff"
    },
    "jquery/jquery.d.ts": {
      "commit": "40c60850ad6c8175a62d5ab48c4e016ea5b3dffe"
    },
    "angularjs/angular.d.ts": {
      "commit": "40c60850ad6c8175a62d5ab48c4e016ea5b3dffe"
    },
    "angularjs/angular-route.d.ts": {
      "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff"
    },
    "angularjs/angular-cookies.d.ts": {
      "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff"
    },
    "angularjs/angular-animate.d.ts": {
      "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff"
    },
    "angularjs/angular-resource.d.ts": {
      "commit": "40c60850ad6c8175a62d5ab48c4e016ea5b3dffe"
    },
    "angular-ui-router/angular-ui-router.d.ts": {
      "commit": "40c60850ad6c8175a62d5ab48c4e016ea5b3dffe"
    }
  }
}

我有点迷失于我已经或者没有做过的事情。奇怪的是,一切仍然100%工作。所以我仍然在为ng.获取智能它只是说有错误,每次构建我都会在所有文件上出现多重错误。

更新

我最终在第import ng = angular;行评论了17,然后在angular.d.ts

ng.auto.IInjectorService;更改为angular.auto.IInjectorService; >

这意味着角度应用程序中的每个引用现在都使用173而不是angular,这不是理想的,但它现在可以做到。我很确定这不是一个"最佳实践"修复。

https://github.com/DefinitelyTyped/DefinitelyTyped/issues/7284

1 个答案:

答案 0 :(得分:1)

检查您为angular-ui-router安装额外的.d.ts文件的位置。像

这样的东西
./bower_components/angular-ui-router/api/angular-ui-router.d.ts

删除该.d.ts文件并重新启动VSCode。如果没有,请检查项目中的其余文件夹是否有任何重复的.d.ts文件。这就是我解决这个问题的原因。

相关问题