如何在 Angular 4 应用程序中使用 TypeScript 中的 FileSystem API?
我将 @types/filesystem
添加到 devDependencies
,但我仍然收到类似
Property 'resolveLocalFileSystemURL' does not exist on type 'Window'.
Cannot find name 'FileError'.
Cannot find name 'FileEntry'.
我的 tsconfig.json
和 angular-cli 生成的几乎一样,我只是在 中添加了
:"node_modules/typed-cordova-plugin-purchase
>typeRoots
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types",
"node_modules/typed-cordova-plugin-purchase"
],
"lib": [
"es2016",
"dom"
]
}
}
我应该导入任何东西吗? 有没有在 Typescript 中使用 FileSystem 的例子?
最佳答案
我最终通过将 types
添加到 tsconfig.json
,实际上是 tsconfig.app.json
使其工作(我正在使用 angular CLI 1.0.1)
"types": [
"cordova",
"cordova-plugin-file"
]
使用 @types/filesystem
是不够的,因为那里没有定义 FileError
,这就是我使用 "@types/cordova-plugin-file的原因
.
关于angular - typescript 中的文件系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43693819/