【问题标题】:lint gives warning when concat string using $ operatorlint 在使用 $ 运算符连接字符串时发出警告
【发布时间】:2022-08-12 18:14:27
【问题描述】:

对于以下方法,lint 会发出警告

public async listUsers(startIndex: number, count = this.pageSize): Promise<AxiosResponse> {
    logger.trace(\'Entering List User\');

    return this.axiosInstance.get(\'/Users?startIndex=${startIndex}&count=${count}\', {
        method: HttpMethod.GET
    });
}

皮棉警告:

警告 \'count\' 被赋值但从未使用过 @typescript-eslint/no-unused-vars

  • 这可能是一个转录错误,但您需要使用反引号 ` 在模板文字中使用表达式

标签: typescript lint


【解决方案1】:
public async listUsers(startIndex: number, count = this.pageSize): Promise<AxiosResponse> {
    logger.trace('Entering List User');

    return this.axiosInstance.get(`/Users?startIndex=${startIndex}&count=${count}`, {
        method: HttpMethod.GET
    });
}

【讨论】:

    猜你喜欢
    • 2012-05-07
    • 2020-11-07
    • 2015-06-30
    • 2012-11-11
    • 1970-01-01
    • 1970-01-01
    • 2014-02-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多