cordova-plugin-file
cordova-plugin-file copied to clipboard
fix(types): Adjust types to fix incompatibilities with TypeScript 4.4+
Platforms affected
Typescript type definitions only. No platform impacts.
Motivation and Context
Changes in libdom by the TypeScript project led to conflicting definitions with this plugin. This is an attempt following on from #500 to try and address the compatibility problem.
Description
The key point that joins libdom and this plugin together are via the root property
on the FileSystem interface. This results in the DirectoryEntry and Entry types needing
to align with libdom's FileSystemDirectoryEntry & FileSystemEntry.
This introduces 3 slight irregularities in order to be compatible with libdom
- getParent successCallback needs to be optional
- getParent errorCallback needs to be typed as a DOMException, despite it being a FileError in reality
- getFile and getDirectory success types need to be relaxed to the base Entry
Testing
I've created a test repository with several typescript versions, and ensured each of these compiles without issue: https://github.com/peitschie/cordova-plugin-file-type-tests
Checklist
- [x] I've run the tests to see all new and existing tests pass
- [ ] I added automated test coverage as appropriate for this change
- [ ] Commit is prefixed with
(platform)if this change only applies to one platform (e.g.(android)) - [ ] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
- [ ] I've updated the documentation if necessary