const opts = {
suggestedName: 'data',
types: [
{
description: 'NewCSV',
accept: { 'text/csv': ['.csv'] },
},
],
};
const handle = await (window).showSaveFilePicker(opts);
现在,类型错误属性'showSaveFilePicker‘在类型'Window & typeof globalThis'上不存在,提供类型为的解决了类型错误的问题。
const handle = await (<any>window).showSaveFilePicker(opts);
但是,它仍将显示any
类型化值的不安全调用的eslint错误。因此,我知道的唯一解决方案是禁用文件的eslint。还有其他方法可以避免类型错误和eslint错误吗?
发布于 2022-03-03 20:32:28
似乎类型记录文件系统访问API的类型定义当前已被破坏: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的类型字段:
"compilerOptions": {
"types": [ "@types/wicg-file-system-access"]
}
https://stackoverflow.com/questions/71309058
复制相似问题