我遇到过几种类型的错误,我可以在Meteor / Angular代码中编写,这些错误似乎会破坏编译器而不会抛出错误。一些例子:
export const foo = {
propA: 'abc',
propB: 123;
propc: 'value'
}
错误地在对象中间的分号会严重破坏。 另:
private _functionName( param1: string, param2: boolean; param3: string ): void { // do stuff here }
再次错误地放置了分号。第三:
const propertyName = thisArray.map( thing => return thing._id );
回调函数应该用大括号括起来(分号可能也有帮助)。第四:
import style from './this.component.scss';
其中指定的.scss文件不存在(如果它存在但是将传递0字节 - 只有它不存在才会失败)。
这些错误中的每一个都导致服务器端的清理编译,以及带有挂起在加载屏幕上的应用程序的无错误客户端控制台。
存在是否/如何复制的问题;以下是我正在亚马逊Linux上工作的具体环境参数。
"devDependencies": {
"@types/chai": "3.4.34",
"@types/meteor": "^1.3.31",
"@types/mocha": "2.2.34",
"chai": "3.5.0",
"chai-spies": "0.7.1"
},
"dependencies": {
"@angular/animations": "^4.1.3",
"@angular/common": "^4.1.3",
"@angular/compiler": "^4.1.3",
"@angular/core": "^4.1.3",
"@angular/forms": "^4.1.3",
"@angular/http": "^4.1.3",
"@angular/material": "^2.0.0-beta.5",
"@angular/platform-browser": "^4.1.3",
"@angular/platform-browser-dynamic": "^4.1.3",
"@angular/router": "^4.1.3",
"@mahpah/angular-cropper": "0.0.1",
"@ngx-translate/core": "^6.0.1",
"@types/htmlparser2": "^3.7.29",
"angular-draggable-droppable": "^1.0.1",
"angular2-meteor": "^0.7.1",
"angular2-meteor-accounts-ui": "^1.0.0",
"angular2-meteor-polyfills": "^0.1.1",
"angular2-meteor-tests-polyfills": "0.0.2",
"babel-runtime": "^6.23.0",
"hammerjs": "^2.0.8",
"htmlparser2": "^3.9.2",
"meteor-node-stubs": "^0.2.11",
"meteor-rxjs": "^0.4.7",
"ng-gallery": "^0.7.1",
"ngx-pagination": "^3.0.0",
"reflect-metadata": "^0.1.10",
"rxjs": "^5.2.0",
"simpl-schema": "^0.2.3",
"zone.js": "^0.8.11"
}
meteor-base@1.1.0 # Packages every Meteor app needs to have
mobile-experience@1.0.4 # Packages for a great mobile UX
mongo@1.2.0 # The database Meteor supports right now
reactive-var@1.0.11 # Reactive variable for tracker
tracker@1.1.3 # Meteor's client-side reactive programming library
standard-minifier-css@1.3.4 # CSS minifier run for production mode
standard-minifier-js@2.1.1 # JS minifier run for production mode
es5-shim@4.6.15 # ECMAScript 5 compatibility for older browsers.
angular2-compilers
practicalmeteor:mocha
xolvio:cleaner
hwillson:stub-collections
dispatch:mocha-phantomjs
shell-server@0.2.4
aldeed:collection2-core
aldeed:schema-deny
aldeed:schema-index
mdg:validated-method
mdg:validation-error
accounts-password@1.4.0
alanning:roles
tmeasday:publish-counts
dburles:collection-helpers
matb33:collection-hooks
email@1.2.3
edgee:slingshot
dynamic-import@0.1.1
http@1.2.12
{
"compilerOptions": {
"target": "es5",
"lib": [
"es6",
"dom"
],
"module": "commonjs",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"sourceMap": true
},
"exclude": [
"node_modules"
],
"compileOnSave": false,
"angularCompilerOptions": {
"genDir": "aot",
"skipMetadataEmit": true
}
}
我的问题是:
是否有一个linter或一些我没有看到的调试器日志有助于排除故障?我认识到某些IDE会突出显示这些错误(尤其是缺少的SCSS文件),但这并不能回答我的问题。
提前致谢!
答案 0 :(得分:1)
我不确定你的问题是什么,但在你提到的默认编译器设置的所有情况下,我都会收到错误。以下代码段:
import style from './bla'; // with bla.js being an empty file
export const foo = {
propA: 'abc',
propB: 123;
propc: 'value'
}
function _functionName( param1: string, param2: boolean; param3: string ): void {}
产生以下输出:
test.ts(5,13): error TS1005: ',' expected.
test.ts(10,56): error TS1005: ',' expected.
虽然空模块不会产生编译器错误,但它会在VS代码中警告您。
如果你想要一个针对Typescript的linter,tslint是一个很棒的工具。但是你的前两个肯定是编译器错误(至少在TS 2.5中)