Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use TVReturnType to prevent circular references #39

Merged
merged 1 commit into from
Apr 29, 2023

Conversation

mskelton
Copy link
Collaborator

@mskelton mskelton commented Apr 26, 2023

Description

The TypeScript types were behaving very slow and after some digging it was due to a circular reference from ReturnType<TV>. Swapping that out with TVReturnType drastically improves the experience in the editor.

There are a bunch of other issues with the types related to missing generic arguments and such that I plan on helping fix in future PRs, but wanted to get this out there since it's a small fix with a big performance improvement.

Additional context

The videos below show the difference in time for errors appearing before and after this change.

Before

Screen.Recording.2023-04-25.at.9.28.41.PM.mov

After

Screen.Recording.2023-04-25.at.9.29.23.PM.mov

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Follow the Style Guide.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).

@@ -42,7 +42,7 @@ export declare const cnBase: <T extends CnOptions>(...classes: T) => CnReturn;
export declare const cn: <T extends CnOptions>(...classes: T) => (config?: TWMConfig) => CnReturn;

// compare if the value is true or array of values
export type isTrueOrArray<T> = T extends true | (infer U)[] ? true : false;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

U wasn't used, so using a simpler unknown[] is fine here.

@mskelton mskelton mentioned this pull request Apr 27, 2023
8 tasks
Copy link
Member

@tianenpang tianenpang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this is a huge improvement! Thank you @mskelton 🚀

CC @jrgarciadev

@jrgarciadev
Copy link
Member

Huge thanks! @mskelton 🚀

@jrgarciadev jrgarciadev merged commit f766680 into heroui-inc:main Apr 29, 2023
@mskelton mskelton deleted the fix-editor-perf branch July 26, 2023 05:21
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants