apache / apache/cordova-plugin-file

Fix type misaligments in newer TypeScript versions

Open
#563 2 comments 5 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
744
Forks
754
Avg merge
3d 4h
Merged PRs (30d)
1

Description

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used [patch-package](https://github.com/ds300/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](https://github.com/microsoft/TypeScript/blob/main/src/lib/dom.generated.d.ts#L5867):

```diff
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](https://github.com/ds300/patch-package/issues/296).

Contributor guide

Open the contributing guide

Research direction

Start with types/index.d.ts and compare its FileSystem declarations with the TypeScript 4.8 DOM definitions linked in the issue. Update the declarations to match the stated readonly and type changes, then verify that the reported subsequent-property-declarations error no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
mobile-dev
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.