You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2021/09/27 07:15:13 UTC

[GitHub] [cordova-plugin-file] fcamblor opened a new pull request #500: Make types compatible with Typescript 4.4

fcamblor opened a new pull request #500:
URL: https://github.com/apache/cordova-plugin-file/pull/500


   ### Platforms affected
   None, Typescript type definition only
   
   
   ### Motivation and Context
   Typescript 4.4 has introduced a lot of changes in `lib.dom.d.ts` file, which raises a lot of compilation errors with the plugin.
   These changes makes it compatible with it.
   
   
   ### Description
   - `Entry` renamed to `FileSystemEntry`
   - `FileEntry` renamed to `FileSystemFileEntry`
   - `DirectoryEntry` renamed to `FileSystemDirectoryEntry`
   - Commented `FileSystem` interface which already exists into `lib.dom.d.ts`
   - Commented field duplications for those interfaces, to avoid error `TS2687`
   ```
        error TS2687: All declarations of 'xxx' must have identical modifiers.
   ````
   
   Most of the changes are naming changes to follow Typescript renames.
   
   However, this may require some changes on the application side if :
   - the old Type names were referenced in your code (migrate them to the new name, or make type alias with the old name if there are too much occurences of it in your code)
   - If you are on a TS version older than 4.4, you may miss the commented parts if you were relying on it in your code. In that case, I'd suggest to declare following interfaces somewhere in your code : 
   ```
   declare interface FileSystem {
       /* The name of the file system, unique across the list of exposed file systems. */
       name: string;
       /** The root directory of the file system. */
       root: FileSystemDirectoryEntry;
   }
   
   declare interface FileSystemEntry {
       /** FileSystemEntry is a file. */
       isFile: boolean;
       /** FileSystemEntry is a directory. */
       isDirectory: boolean;
       /** The name of the entry, excluding the path leading to it. */
       name: string;
       /** The full absolute path from the root to the entry. */
       fullPath: string;
       /** The file system on which the entry resides. */
       filesystem: FileSystem;
   }
   ```
   
   ⚠️ Important notes : 
   - I updated `doc/plugins.md` file to reflect the naming changes, but I'm unsure of the pertinence of it given that we're going to have discrepancies (in namings) between native code's semantics and javascript's semantic. I can rollback these change if you prefer.
   - Some care should be added to the `README`'s `Upgrading notes` section to pinpoint these changes (I didn't added any entry as I don't know which version of the plugin may be concerned by this change)
   
   ### Testing
   There wasn't any TS-based tests in place currently, didn't spent time to introduce it as I'd consider it as a whole dedicated topic.
   
   ### 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](https://help.github.com/articles/closing-issues-using-keywords/))
   - [x] I've updated the documentation if necessary
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org