typescript - tslint:dsiable 不起作用。可能的原因是什么?
问题描述
尽管已经设置,但tslint:disable
我收到了 tslint 警告。
我得到的具体警告是:
[ts] Argument of type 'string' is not assignable to parameter of type 'RequestInit | undefined'.
(parameter) options: string
[ts] Parameter 'response' implicitly has an 'any' type.
(parameter) response: Response
这是我的代码。
/* tslint:disable */
// imports
export async function fetchUrl(url: string, options: string) {
return fetch(url, options)
.then(async (response) => response.json())
.then((data: any) => data.data);
}
// other code
/* tslint:enable */
为什么即使我禁用了 tslint 也会收到这些警告?
如何摆脱此文件的错误消息?
解决方案
这些错误来自 TypeScript 编译器本身,如[ts]
错误中所示。
以下将消除错误,但您需要检查使用该功能的任何内容是否正确。即具有有效options
参数。
export async function fetchUrl(url: string, options: RequestInit) {
return fetch(url, options)
.then(async (response: Response) => response.json())
.then((data: any) => data.data);
}
推荐阅读
- python - 找不到pyimagej模块imagej的问题
- python - 使用 Beautiful Soup python 在标签中添加或更新属性
- yaml - 如何使用 Terraform 访问 yaml 文件中的地图地图
- c# - 安装 TelerikUI 控件后,“ResolvePackageAssets”和“GetPackageDirectories”任务均失败
- microsoft-graph-api - 图形邮件 API 返回 504 网关超时错误
- excel - 将 Excel VBA 用户表单另存为 PDF
- figure - 图与文字之间的间距
- elasticsearch - 无法为持久文档时看到的类型类的未知值写入 xcontent
- firebase - 将用户添加到 firebase 项目中的单个应用程序
- node.js - 在将它们与 FFmpeg 连接之前如何检查文件是否损坏?