我遇到了几种类型的错误,我可以在 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 字节将通过 - 只有它不存在的情况才会失败)。
这些错误中的每一个都会导致在服务器端进行干净的编译,并在加载屏幕上挂起一个应用程序的无错误客户端控制台。
存在是否/如何重现的问题;下面是我在 Amazon 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 文件),但这并不能回答我的问题。
提前致谢!
最佳答案
我不确定您的问题是什么,但是在您使用默认编译器设置提到的所有情况下,我都会遇到错误。以下片段:
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 Code 中警告您这一点。
如果你想要一个用于 Typescript 的 linter,tslint 是一个很棒的工具。但是你的前两个肯定是编译器错误(至少在 TS 2.5 中)
关于typescript - 克服 Meteor/Typescript/Angular 编译器丢失错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46136171/