Skip to content

Comments

fix: Make types of File and Folder more explicit#1118

Merged
susnux merged 1 commit intomainfrom
fix/stricter-types
Nov 15, 2024
Merged

fix: Make types of File and Folder more explicit#1118
susnux merged 1 commit intomainfrom
fix/stricter-types

Conversation

@susnux
Copy link
Contributor

@susnux susnux commented Nov 14, 2024

Both inherit from Node which is generic, thus e.g. the mime field is of type string. But for folders the mime can never be something different to 'httpd/unix-directory'.
So the correct type would be the string literal 'httpd/unix-directory'.

The same for the type attribute for File and Folder.


⬆️ While this could be seen as an improvement it actually fixes a Typescript issue:

const IFolder = new Folder({ ... })

This I expect to work, but it fails with:

Type 'Folder' is not assignable to type 'IFolder'.
Types of property 'type' are incompatible.
Type 'FileType' is not assignable to type 'FileType.Folder'.

Both inherit from Node which is generic, thus e.g. the `mime` field is of type `string`.
But for folders the mime can never be something different to
`'httpd/unix-directory'`.
So the correct type would be the string literal
`'httpd/unix-directory'`.

The same for the `type` attribute for `File` and `Folder`.

Signed-off-by: Ferdinand Thiessen <[email protected]>
@susnux susnux added type: bug 🐛 Something isn't working 3. to review 3️⃣ Waiting for reviews labels Nov 14, 2024
@susnux susnux requested review from Pytal and skjnldsv November 14, 2024 19:43
@codecov
Copy link

codecov bot commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.77%. Comparing base (ca0ed89) to head (19395e5).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1118   +/-   ##
=======================================
  Coverage   91.77%   91.77%           
=======================================
  Files          23       23           
  Lines         632      632           
  Branches      166      166           
=======================================
  Hits          580      580           
  Misses         45       45           
  Partials        7        7           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codecov
Copy link

codecov bot commented Nov 14, 2024

Bundle Report

Bundle size has no change ✅

@susnux susnux merged commit f1d1a84 into main Nov 15, 2024
@susnux susnux deleted the fix/stricter-types branch November 15, 2024 10:59
@skjnldsv skjnldsv mentioned this pull request Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review 3️⃣ Waiting for reviews type: bug 🐛 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants