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: tsc error #3362

Merged
merged 6 commits into from
Jul 7, 2024
Merged

fix: tsc error #3362

merged 6 commits into from
Jul 7, 2024

Conversation

winchesHe
Copy link
Member

@winchesHe winchesHe commented Jun 29, 2024

📝 Description

Fix all the typescript error in project

image

Add a brief description

⛳️ Current behavior (updates)

Please describe the current behavior that you are modifying

🚀 New behavior

Please describe the behavior or changes this PR adds

💣 Is this a breaking change (Yes/No):

📝 Additional Information

Summary by CodeRabbit

  • New Features

    • Improved type safety and clarity across various components and scripts.
  • Bug Fixes

    • Addressed TypeScript compiler errors in the @nextui-org/aria-utils package.
  • Refactor

    • Updated type declarations for states and props in multiple components to improve robustness and maintainability.
  • Chores

    • Modified TypeScript configuration to allow implicit any types.

Copy link

changeset-bot bot commented Jun 29, 2024

🦋 Changeset detected

Latest commit: fb0a094

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
@nextui-org/aria-utils Patch
@nextui-org/accordion Patch
@nextui-org/autocomplete Patch
@nextui-org/date-picker Patch
@nextui-org/dropdown Patch
@nextui-org/listbox Patch
@nextui-org/menu Patch
@nextui-org/popover Patch
@nextui-org/select Patch
@nextui-org/tabs Patch
@nextui-org/tooltip Patch
@nextui-org/react Patch
@nextui-org/slider Patch
@nextui-org/snippet Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jun 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextui-docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 6, 2024 10:18am
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 6, 2024 10:18am

Copy link
Contributor

coderabbitai bot commented Jun 29, 2024

Walkthrough

A patch was made to address TypeScript compiler errors, and various components were updated to improve type safety and consistency. This includes adjustments in type declarations, handling of state, and component rendering logic. These changes aim to enhance reliability and maintainability, particularly in handling dynamic collections, ensuring better developer experience with fewer type-related issues.

Changes

Files/Groups Change Summary
.changeset/eight-worms-cough.md Introduced a patch for the @nextui-org/aria-utils package to resolve TypeScript compiler errors.
packages/components/autocomplete/stories/...
packages/components/badge/stories/...
packages/components/calendar/src/...
apps/docs/scripts/update-search-meta.ts
Updated type declarations, handleSelectionChange function parameters, and state initialization for ControlledTemplate, Badge, and CalendarBase components.
packages/components/select/__tests__/select.test.tsx
apps/docs/components/code-window/code-block.tsx
apps/docs/components/sonar-pulse.tsx
Modified rendering logic for SelectItem components, added TypeScript type ignores in form data logging, and changed array types from any to React.ReactNode.
packages/utilities/aria-utils/src/collections/section.ts Excluded the "children" property from the HTMLNextUIProps type in section.ts.
tsconfig.json Added "noImplicitAny": false under compiler options to allow implicit any types.

Assessment against linked issues

Objective (Issue #) Addressed Explanation
Fix TypeScript typing issues with Listbox and Autocomplete components (#2365, #2314, #2505)
Ensure no compiler errors and correct type handling in updated components (#2365, #2314, #2505)
Maintain proper rendering logic and state management for components (#2365, #2314)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range and nitpick comments (1)
packages/components/calendar/src/calendar-base.tsx (1)

Line range hint 169-174: Provide an explicit type for the button element.

The default type of a button is submit, which may cause unintended form submissions. Specify the button type explicitly.

- <button
+ <button type="button"
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 78d4216 and 425b7d5.

Files selected for processing (7)
  • .changeset/eight-worms-cough.md (1 hunks)
  • packages/components/autocomplete/stories/autocomplete.stories.tsx (1 hunks)
  • packages/components/badge/stories/badge.stories.tsx (1 hunks)
  • packages/components/calendar/src/calendar-base.tsx (1 hunks)
  • packages/components/select/tests/select.test.tsx (6 hunks)
  • packages/utilities/aria-utils/src/collections/section.ts (1 hunks)
  • tsconfig.json (1 hunks)
Files skipped from review due to trivial changes (2)
  • .changeset/eight-worms-cough.md
  • tsconfig.json
Additional context used
Biome
packages/utilities/aria-utils/src/collections/section.ts

[error] 9-9: Don't use '{}' as a type.

Prefer explicitly define the object shape. '{}' means "any non-nullable value".

(lint/complexity/noBannedTypes)

packages/components/calendar/src/calendar-base.tsx

[error] 169-174: Provide an explicit type prop for the button element.

The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset

(lint/a11y/useButtonType)

Additional comments not posted (10)
packages/components/badge/stories/badge.stories.tsx (1)

71-71: Ensure args.classNames?.badge is a string before casting.

Casting args.classNames?.badge as a string may hide potential issues if badge is not a string. Ensure that badge is always a string or handle other types appropriately.

- isBordered={(args.classNames?.badge as string)?.includes("bottom")}
+ isBordered={typeof args.classNames?.badge === "string" && args.classNames?.badge.includes("bottom")}
packages/components/calendar/src/calendar-base.tsx (1)

62-63: LGTM!

The type annotations for headers and calendars improve type safety.

packages/components/select/__tests__/select.test.tsx (6)

86-86: Good practice: Added key prop to SelectItem.

Adding a key prop to SelectItem components based on item properties like id helps React optimize rendering.


113-113: Improved type safety: Updated type declaration for SelectSection.

The type declaration for SelectSection has been updated to use a more specific type, improving type safety.


366-366: Good practice: Added key prop to SelectItem.

Adding a key prop to SelectItem components based on item properties like id helps React optimize rendering.


406-406: Good practice: Added key prop to SelectItem.

Adding a key prop to SelectItem components based on item properties like key helps React optimize rendering.


564-564: Use @ts-ignore sparingly.

The @ts-ignore directive is used to bypass TypeScript errors. Ensure there is a valid reason for ignoring the error to avoid masking potential issues.


652-652: Good practice: Added key prop to SelectItem.

Adding a key prop to SelectItem components based on item properties like id helps React optimize rendering.

packages/components/autocomplete/stories/autocomplete.stories.tsx (2)

434-434: Improved state handling: Updated value state type to Key | null.

The change from Key to Key | null allows the state to handle a null value, improving the flexibility of the controlled component.


436-436: Improved parameter handling: Updated handleSelectionChange parameter type to Key | null.

The change from Key to Key | null allows the function to handle a null value, improving the flexibility of the selection change handler.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 425b7d5 and 325c677.

Files selected for processing (1)
  • packages/components/select/tests/select.test.tsx (8 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/components/select/tests/select.test.tsx

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
apps/docs/scripts/update-search-meta.ts (1)

Line range hint 57-57: Remove redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.

-  const title = !!frontMatter.title ? frontMatter.title : "";
+  const title = frontMatter.title ? frontMatter.title : "";
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 325c677 and fc876a6.

Files selected for processing (3)
  • apps/docs/components/code-window/code-block.tsx (1 hunks)
  • apps/docs/components/sonar-pulse.tsx (1 hunks)
  • apps/docs/scripts/update-search-meta.ts (1 hunks)
Files not reviewed due to errors (1)
  • apps/docs/components/code-window/code-block.tsx (no review received)
Files skipped from review due to trivial changes (1)
  • apps/docs/components/sonar-pulse.tsx
Additional context used
Biome
apps/docs/scripts/update-search-meta.ts

[error] 57-57: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)

apps/docs/components/code-window/code-block.tsx

[error] 81-81: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 94-94: This var should be declared at the root of the enclosing function.

The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.

(lint/correctness/noInnerDeclarations)


[error] 105-105: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 111-111: Avoid passing content using the dangerouslySetInnerHTML prop.

Setting content using code can expose users to cross-site scripting (XSS) attacks

(lint/security/noDangerouslySetInnerHtml)


[error] 158-158: Avoid passing content using the dangerouslySetInnerHTML prop.

Setting content using code can expose users to cross-site scripting (XSS) attacks

(lint/security/noDangerouslySetInnerHtml)

Additional comments not posted (1)
apps/docs/scripts/update-search-meta.ts (1)

99-99: LGTM!

@wingkwong wingkwong added this to the v2.4.3 milestone Jun 29, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fc876a6 and a050329.

Files selected for processing (1)
  • apps/docs/scripts/update-search-meta.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/docs/scripts/update-search-meta.ts

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a050329 and fb0a094.

Files selected for processing (2)
  • apps/docs/scripts/update-search-meta.ts (2 hunks)
  • packages/components/badge/stories/badge.stories.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • apps/docs/scripts/update-search-meta.ts
  • packages/components/badge/stories/badge.stories.tsx

@wingkwong wingkwong merged commit 60bb09f into canary Jul 7, 2024
8 checks passed
@wingkwong wingkwong deleted the fix-tsc-error branch July 7, 2024 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants