微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Angular 2在Sublime Text 3中有错误

我尝试在 Windows上的Angular 2中基于以下存储库启动一个新项目: https://github.com/mgechev/angular2-seed

一切正常(npm install,npm start,…),但Sublime Text 3向我展示了一些在执行项目时不存在的错误.

以下是我遵循的步骤:

$git clone https://github.com/mgechev/angular2-seed.git
$cd angular2-seed
$npm install

然后我用Sublime Text打开项目(使用TypeScript package),我在代码中遇到一些错误/警告.

错误#1

带@Component装饰器的类显示以下错误

Experimental support for decorators is a feature that is subject to change in a future release. Set the ‘experimentalDecorators’ option to remove this warning.

(它忽略了“experimentalDecorators”行:tsconfig.json中的true)

错误#2

例如,在src / client / app / about / about.component.ts中,在行上:

moduleId: module.id,

Sublime显示错误

Cannot find name ‘module’.

tsconfig.json

{
  "compilerOptions": {
    "target": "es5","module": "commonjs","declaration": false,"removeComments": true,"noLib": false,"emitDecoratorMetadata": true,"experimentalDecorators": true,"lib": ["es6","es2015","dom"],"sourceMap": true,"pretty": true,"allowUnreachableCode": false,"allowUnusedLabels": false,"noImplicitAny": true,"noImplicitReturns": true,"noImplicitUseStrict": false,"noFallthroughCasesInSwitch": true,"typeRoots": [
      "./node_modules/@types","./node_modules"
    ],"types": [
      "node"
    ]
  },"exclude": [
    "node_modules","dist","src"
  ],"compileOnSave": false
}

package.json

https://github.com/mgechev/angular2-seed/blob/27db8a19f70470f5110482df1a4debc1100ec347/package.json

你为什么我有这2个错误?我可以发展,但不是很愉快.

由于这个链接,我解决了我的问题: https://github.com/Microsoft/TypeScript-Sublime-Plugin/issues/470

总结一下:

>转到用户首选项(Ctrl Shift P>首选项:设置)>添加以下行:“typescript_tsdk”:“C:/….. / npm / node_modules / typescript / lib”,(带有相应的链接)>重新启动Sublime文本>当光标位于module.id上时,按F12键测试它是否在about.component.ts文件中有效>享受!

原文地址:https://www.jb51.cc/angularjs/141035.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐