我们希望希望通过命令行选项配置TSC,以在开发人员使用隐式类型表达式而不是下面的显式代码声明类字段时生成错误。
class Appliance {
//coding style we want to enforce:
private _group:Group = new Group();
//coding style we want to prevent by issuing error:
private _group = new Group();
//coding style we want to enforce as it does not rely only on
//constructor parameters list for declaration
public assetTag:EquipmentTag;
public constructor(assetTag:AssetTag,
//coding style we want to prevent by issuing error if
//no explicit declaration above constructor
supplier:Company) {
this.assetTag = assetTag; //coding style we want to enforce
}
}
我们对TSC使用严格模式,但仍然允许使用一些随意的编码样式,如图所示。
我们可以使用任何TSC选项超越严格模式并强制遵守某些编码风格吗?