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: Exact optional property types #205

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

JeongJuhyeon
Copy link

What kind of change does this PR introduce?

Bug fix and TS config update

What is the current behavior?

The StorageFileApi.bucketId field type is bucketId?: string, which breaks when exactOptionalPropertyTypes is on. This causes headaches for folks trying to use the library with the flag on.

What is the new behavior?

  1. Fixed StorageFileApi.bucketId field type: bucketId: string | undefined
  2. Enabled "exactOptionalPropertyTypes": true in TS config

Now it should play nice with the flag on without breaking existing setups.

Additional context

Here's why I think this change is useful:

  • TypeScript itself recommends using this flag. The reason it is not in strict is just to avoid breaking too much existing user code.

  • Right now, anyone with this flag on can't use the library without it failing to compile. Using skipLibCheck isn't great because it skips all .d.ts files, including user-made ones (see this issue).

  • Except for the one field I fixed, the package already follows this rule.

  • In my current project with 58 libraries, this is the only one that breaks with the flag on, indicating it's already a standard in the ecosystem.

These tweaks should make the library more robust and play better with strict TS setups, without causing issues for current users. Let me know if you need any more info!

@JeongJuhyeon JeongJuhyeon changed the title Exact optional property types fix: Exact optional property types Jul 4, 2024
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 this pull request may close these issues.

1 participant