const opts = {
suggestedName: 'data',
types: [
{
description: 'NewCSV',
accept: { 'text/csv': ['.csv'] },
},
],
};
const handle = await (window).showSaveFilePicker(opts);
现在我有类型错误类型“Window & typeof globalThis”上不存在属性“showSaveFilePicker”,提供类型为any解决了类型错误的问题。
const handle = await (<any>window).showSaveFilePicker(opts);
但仍然会显示 eslint 错误不安全的呼叫any
输入值。所以我知道的唯一解决方案是禁用该文件的 eslint。有没有其他方法可以避免类型错误和 eslint 错误?
TypeScript 文件系统访问 API 的类型定义目前似乎已损坏:https://github.com/microsoft/vscode/issues/141908 https://github.com/microsoft/vscode/issues/141908
现在,尝试安装该软件包@types/wicg-file-system-access
修复类型:
# Yarn
yarn add --dev @types/wicg-file-system-access
# NPM
npm install --save-dev @types/wicg-file-system-access
您还需要使用以下内容更新 tsconfig.json 的 types 字段:
"compilerOptions": {
"types": [ "@types/wicg-file-system-access"]
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)