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

feat: undefinedOnPartialDeep type #700

Merged

Conversation

Emiyaaaaa
Copy link
Collaborator

@Emiyaaaaa Emiyaaaaa commented Oct 8, 2023

Fixes #681

Hello Everyone~

I have a question about testing and want some suggest or help:

  • This type is only useful when exactOptionalPropertyTypes enabled, but this option is disable in type-fest, so tests for this type must pass regardless of bugs.

Then I have an idea:

  1. replace this line undefined with another any flag type like type FlagType = 1 by generic type. example undefinedOnPartialDeep<T, UnionType = FlagType>.
  2. test if undefinedOnPartialDeep<{ a?: string }, FlagType> is assignable to type { a?: string | FlagType } or not.
  3. export a stable new type like type NewStableType<T> = undefinedOnPartialDeep<T, undefined>, because 2nd generic type is just for testing, don't hope to export for user. (ignore type name, maybe is type UndefinedOnPartialDeep<T> = someOtherName<T, undefined>)

@sindresorhus
Copy link
Owner

// @kachkaev

@sindresorhus
Copy link
Owner

This type is only useful when exactOptionalPropertyTypes enabled, but this option is disable in type-fest, so tests for this type must pass regardless of bugs.

You could create a separate test file in a subfolder, give it a tsconfig file that extends the existing ones, but changes that flag, and then just run tsc --noEmit on that file.

@Emiyaaaaa
Copy link
Collaborator Author

This type is only useful when exactOptionalPropertyTypes enabled, but this option is disable in type-fest, so tests for this type must pass regardless of bugs.

You could create a separate test file in a subfolder, give it a tsconfig file that extends the existing ones, but changes that flag, and then just run tsc --noEmit on that file.

thanks! fixed in the lastest commit. but tsc seems just could test assignable, expectType is not working.

@sindresorhus sindresorhus merged commit d8b44cb into sindresorhus:main Oct 18, 2023
6 checks passed
@sindresorhus
Copy link
Owner

@Emiyaaaaa Thank you 🙏

It would be amazing if you would be willing to help review some of the open pull requests too: https://github.com/sindresorhus/type-fest/pulls

@Emiyaaaaa
Copy link
Collaborator Author

@Emiyaaaaa Thank you 🙏

It would be amazing if you would be willing to help review some of the open pull requests too: https://github.com/sindresorhus/type-fest/pulls

Thanks for the invite, I'll try my best.

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.

UndefinedOnPartialDeep (opposite of PartialOnUndefinedDeep)
2 participants