Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type misaligments in newer TypeScript versions #563

Open
hupf opened this issue Apr 3, 2023 · 2 comments 路 May be fixed by #588
Open

Fix type misaligments in newer TypeScript versions #563

hupf opened this issue Apr 3, 2023 · 2 comments 路 May be fixed by #588

Comments

@hupf
Copy link

hupf commented Apr 3, 2023

Hi! 馃憢

Firstly, thanks for your work on this project! 馃檪

Today I used patch-package to patch cordova-plugin-file@7.0.0 for the project I'm working on.

Apparently the type definitions provided by this plugin don't work with newer TypeScript versions (I'm using 4.8). The result is a mismatch of the types with the TypeScript internal types, causing a Subsequent property declarations must have the same type error.

Here is the diff that solved my problem by align the types to TypeScript's ones:

diff --git a/node_modules/cordova-plugin-file/types/index.d.ts b/node_modules/cordova-plugin-file/types/index.d.ts
index 469d862..c8b1b86 100644
--- a/node_modules/cordova-plugin-file/types/index.d.ts
+++ b/node_modules/cordova-plugin-file/types/index.d.ts
@@ -44,9 +44,9 @@ interface Window {
 /** This interface represents a file system. */
 interface FileSystem {
     /* The name of the file system, unique across the list of exposed file systems. */
-    name: string;
+    readonly name: string;
     /** The root directory of the file system. */
-    root: DirectoryEntry;
+    readonly root: FileSystemDirectoryEntry;
 }
 
 /**

This issue body was partially generated by patch-package.

@ajuanjojjj
Copy link

ajuanjojjj commented Jul 27, 2023

Doing so seems to break the examples in the repo (And I'm assuming that the plugin in general), since FileSystemDirectoryEntry is not assignable to DirectoryEntry

I'd suggest just renaming the interface to something that doesn't coincide with the global new one;

diff --git a/index.d.ts b/index.d.ts
--- a/index.d.ts
+++ b/index.d.ts
@@ -18,5 +18,5 @@ interface Window {
                type: LocalFileSystem,
                size: number,
-        successCallback: (fileSystem: FileSystem) => void,
+        successCallback: (fileSystem: FileSystemCordova) => void,
                errorCallback?: (fileError: FileError) => void): void;
        /**
@@ -43,5 +43,5 @@ interface Window {

 /** This interface represents a file system. */
-interface FileSystem {
+interface FileSystemCordova {
        /* The name of the file system, unique across the list of exposed file systems. */
        name: string;
@@ -64,5 +64,5 @@ interface Entry {
        fullPath: string;
        /** The file system on which the entry resides. */
-    filesystem: FileSystem;
+    filesystem: FileSystemCordova;
        nativeURL: string;
        /**

@ajuanjojjj ajuanjojjj linked a pull request Jul 27, 2023 that will close this issue
5 tasks
@hupf
Copy link
Author

hupf commented Aug 2, 2023

@ajuanjojjj Thanks, that sound's good 馃憤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants