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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Nov 15, 2024
Merged

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 <opensource@fthiessen.de>
@susnux susnux added bug Something isn't working 3. to review labels Nov 14, 2024
@susnux susnux requested review from skjnldsv and Pytal November 14, 2024 19:43
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.

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
18 checks passed
@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 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants