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
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eight-worms-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nextui-org/aria-utils": patch
---

Fix tsc error (#2365, #2314, #2505)
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,9 @@ const ItemStartContentTemplate = ({color, variant, ...args}: AutocompleteProps<A
);

const ControlledTemplate = ({color, variant, ...args}: AutocompleteProps<Animal>) => {
const [value, setValue] = React.useState<Key>("cat");
const [value, setValue] = React.useState<Key | null>("cat");

const handleSelectionChange = (key: Key) => {
const handleSelectionChange = (key: Key | null) => {
setValue(key);
};

Expand Down
2 changes: 1 addition & 1 deletion packages/components/badge/stories/badge.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const defaultProps = {
const Template = (args: BadgeProps) => (
<Badge {...args}>
<Avatar
isBordered={args.classNames?.badge?.includes("bottom")}
isBordered={(args.classNames?.badge as string)?.includes("bottom")}
winchesHe marked this conversation as resolved.
Show resolved Hide resolved
radius={args.shape === "rectangle" ? "lg" : "full"}
src="https://i.pravatar.cc/300?u=a042581f4e29026709d"
/>
Expand Down
4 changes: 2 additions & 2 deletions packages/components/calendar/src/calendar-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export function CalendarBase(props: CalendarBaseProps) {

const currentMonth = state.visibleRange.start;

const headers = [];
const calendars = [];
const headers: React.ReactNode[] = [];
const calendars: React.ReactNode[] = [];

for (let i = 0; i < visibleMonths; i++) {
let d = currentMonth.add({months: i});
Expand Down
15 changes: 8 additions & 7 deletions packages/components/select/__tests__/select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe("Select", () => {
it("should render correctly (dynamic)", () => {
const wrapper = render(
<Select aria-label="Favorite Animal" items={itemsData} label="Favorite Animal">
{(item) => <SelectItem>{item.label}</SelectItem>}
{(item) => <SelectItem key={item.id}>{item.label}</SelectItem>}
</Select>,
);

Expand All @@ -110,7 +110,7 @@ describe("Select", () => {
const wrapper = render(
<Select aria-label="Favorite Animal" items={itemsSectionData} label="Favorite Animal">
{(section) => (
<SelectSection<Item>
<SelectSection<(typeof itemsSectionData)[0]["children"][0]>
aria-label={section.title}
items={section.children}
title={section.title}
Expand Down Expand Up @@ -363,7 +363,7 @@ describe("Select", () => {
label="Test with ID"
onSelectionChange={onSelectionChangeId}
>
{(item) => <SelectItem>{item.value}</SelectItem>}
{(item) => <SelectItem key={item.id}>{item.value}</SelectItem>}
</Select>,
);

Expand Down Expand Up @@ -403,7 +403,7 @@ describe("Select", () => {
label="Test with Key"
onSelectionChange={onSelectionChangeKey}
>
{(item) => <SelectItem>{item.value}</SelectItem>}
{(item) => <SelectItem key={item.key}>{item.value}</SelectItem>}
</Select>,
);

Expand Down Expand Up @@ -561,6 +561,7 @@ describe("Select", () => {
const formData = new FormData(e.target as HTMLFormElement);

/* eslint-disable no-console */
// @ts-ignore
console.log(JSON.stringify(Object.fromEntries(formData)));
}}
>
Expand Down Expand Up @@ -648,19 +649,19 @@ describe("Select with React Hook Form", () => {
wrapper = render(
<form className="flex flex-col gap-4" onSubmit={handleSubmit(onSubmit)}>
<Select data-testid="select-1" items={itemsData} {...register("withDefaultValue")}>
{(item) => <SelectItem key={item.value}>{item.label}</SelectItem>}
{(item) => <SelectItem key={item.id}>{item.label}</SelectItem>}
</Select>

<Select data-testid="select-2" items={itemsData} {...register("withoutDefaultValue")}>
{(item) => <SelectItem key={item.value}>{item.label}</SelectItem>}
{(item) => <SelectItem key={item.id}>{item.label}</SelectItem>}
</Select>

<Select
data-testid="select-3"
items={itemsData}
{...register("requiredField", {required: true})}
>
{(item) => <SelectItem key={item.value}>{item.label}</SelectItem>}
{(item) => <SelectItem key={item.id}>{item.label}</SelectItem>}
</Select>

{errors.requiredField && <span className="text-danger">This field is required</span>}
Expand Down
2 changes: 1 addition & 1 deletion packages/utilities/aria-utils/src/collections/section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ import {HTMLNextUIProps, As} from "@nextui-org/system";
*
*/
export type SectionProps<Type extends As = "div", T extends object = {}> = BaseSectionProps<T> &
winchesHe marked this conversation as resolved.
Show resolved Hide resolved
HTMLNextUIProps<Type>;
Omit<HTMLNextUIProps<Type>, "children">;
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"esModuleInterop": true,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"downlevelIteration": true
"downlevelIteration": true,
"noImplicitAny": false
},
"include": ["packages"],
"exclude": ["**/node_modules", "**/dist", "**/.turbo"]
Expand Down
Loading