生成的打字稿 dto 使用尖括号断言
Generated typescript dtos use angle bracket assertion
我们正在使用提供的 Typescript ServicStack 参考工具生成我们的 DTO,但它会导致 eslint 警告。
失败的 lint 规则是 no-angle-bracket-type-assertion,有关详细信息,请参阅此:https://palantir.github.io/tslint/rules/no-angle-bracket-type-assertion/
我可以禁用规则并抑制它,但这会引入歧义,如此处所述https://basarat.gitbooks.io/typescript/docs/types/type-assertion.html因此建议使用新语法。
目前他们使用尖括号语法 (the ) 生成:
public constructor(init?:Partial<ResponseError>) { (<any>Object).assign(this, init); }
但他们应该使用 'as any' 语法:
public constructor(init?:Partial<ResponseError>) { (Object as any).assign(this, init); }
有谁知道如何更改生成的 DTO 或仅忽略这个文件?
他们是 both valid TypeScript syntax for Type Assertions。 Palintir 不会决定什么是有效语法(TypeScript 编译器就是这样做的),他们只是设置了一些您可以更改的可覆盖默认值。
无论如何,从最新的 v5.5.1 of ServiceStack that's now on MyGet 开始,它采用了 tslint (Object as any)
默认值。
我们正在使用提供的 Typescript ServicStack 参考工具生成我们的 DTO,但它会导致 eslint 警告。
失败的 lint 规则是 no-angle-bracket-type-assertion,有关详细信息,请参阅此:https://palantir.github.io/tslint/rules/no-angle-bracket-type-assertion/
我可以禁用规则并抑制它,但这会引入歧义,如此处所述https://basarat.gitbooks.io/typescript/docs/types/type-assertion.html因此建议使用新语法。
目前他们使用尖括号语法 (the ) 生成:
public constructor(init?:Partial<ResponseError>) { (<any>Object).assign(this, init); }
但他们应该使用 'as any' 语法:
public constructor(init?:Partial<ResponseError>) { (Object as any).assign(this, init); }
有谁知道如何更改生成的 DTO 或仅忽略这个文件?
他们是 both valid TypeScript syntax for Type Assertions。 Palintir 不会决定什么是有效语法(TypeScript 编译器就是这样做的),他们只是设置了一些您可以更改的可覆盖默认值。
无论如何,从最新的 v5.5.1 of ServiceStack that's now on MyGet 开始,它采用了 tslint (Object as any)
默认值。