[英]Why shoudl TSlint be executed after Typescript files is compiled?
According to the official TSLint, TSLint should executed only after the Typescript code is compiled. 根据官方的TSLint,TSLint仅应在Typescript代码编译后执行。 What is the reason behind this?
这背后的原因是什么?
The official TSLint doc: https://palantir.github.io/tslint/usage/cli/ TSLint官方文档: https ://palantir.github.io/tslint/usage/cli/
TSLint runs against a parsed AST (Abstract Syntax Tree) that it receives from TypeScript. TSLint针对从TypeScript接收到的已解析的AST(抽象语法树)运行。 If the AST it receives from TypeScript has errors, its rules' logic might make some incorrect assumptions.
如果从TypeScript接收到的AST有错误,则其规则的逻辑可能会做出一些不正确的假设。
Defining a few of those terms: 定义其中一些术语:
led foo = "bar";
led foo = "bar";
( led
instead of let
) . led
而不是let
) 。 TypeScript will create a different representation of your code than you might expect. let foo: number = "bar";
let foo: number = "bar";
. TSLint has an issue open to discuss whether it shouldn't bother checking code that has syntax or semantic errors: https://github.com/palantir/tslint/issues/3808 TSLint有一个未解决的问题,可以讨论是否应该麻烦检查具有语法或语义错误的代码: https : //github.com/palantir/tslint/issues/3808
Two additional points in favor of not running TSLint on invalid source files: 还有两个要点:不要在无效的源文件上运行TSLint:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.