【发布时间】:2018-05-16 19:30:21
【问题描述】:
我正在使用 Microsoft 的 tslint-microsoft-contrib tslint 配置,我对此非常满意。但是,有一条规则会警告我有关我的代码。我不明白规则描述文本或如何更优雅地解决这个问题。
[tslint] 在拥有模型之外调用主干 get(): this.client.get('locations') (no-backbone-get-set-outside-model)
代码:
import * as Redis from 'ioredis';
import config from './config';
export class RedisWrapper {
private client: Redis.Redis
constructor(redisUrl: string) {
this.client = new Redis(redisUrl)
}
public async getLocations(): ILocation[] {
const locationsResponse: string = await this.client.get('locations')
}
}
在这一行中弹出 tslint 警告:const locationsResponse: string = await this.client.get('locations')
问题:
最初我在项目的另一个地方遇到了这个问题,我认为我应该用 typedef 编写包装器方法,但我也无法让 tslint 对此感到满意。有人能告诉我这条规则的含义以及我该如何解决它吗?
【问题讨论】:
标签: node.js typescript tslint