Thanks to visit codestin.com
Credit goes to github.com

Skip to content

πŸ› Detected case of unusually large amount of typesΒ #8204

@jakeleventhal

Description

@jakeleventhal

Environment information

CLI:
  Version:                      2.3.7
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  BIOME_THREADS:                unset
  NO_COLOR:                     unset
  TERM:                         xterm-256color
  JS_RUNTIME_VERSION:           v22.21.1
  JS_RUNTIME_NAME:              node
  NODE_PACKAGE_MANAGER:         pnpm/10.11.1

Biome Configuration:
  Status:                       Loaded successfully
  Path:                         biome.jsonc
  Formatter enabled:            true
  Linter enabled:               true
  Assist enabled:               true
  VCS enabled:                  true

Workspace:
  Open Documents:               0

What happened?

"use client";

import type {
	DragEndEvent,
	DragStartEvent,
	UniqueIdentifier,
} from "@dnd-kit/core";
import {
	closestCenter,
	DndContext,
	DragOverlay,
	KeyboardSensor,
	PointerSensor,
	useSensor,
	useSensors,
} from "@dnd-kit/core";
import {
	arrayMove,
	SortableContext,
	sortableKeyboardCoordinates,
} from "@dnd-kit/sortable";
import { backdropClasses } from "@mui/material";
import { type FC, type ReactNode, useCallback, useState } from "react";

export interface ActiveItem {
	id: string | number;
	index: number;
}

interface SortableDndContainerProps<T, K extends { id: UniqueIdentifier }> {
	readonly children: ReactNode;
	readonly DragOverlayComponent: FC<Partial<T>>;
	readonly getDragOverlayProps: (item: ActiveItem) => Partial<T>;
	readonly items: Array<K>;
	readonly onChange: (newArray: Array<K>) => void;
}

PointerSensor.activators[0].handler = ({ nativeEvent }) => {
	const targetElement = nativeEvent.target as HTMLElement;

	if (targetElement.classList.contains(backdropClasses.root)) {
		return false;
	}

	let currentElement = targetElement;

	while (currentElement.parentElement) {
		if (currentElement.dataset?.["noDnd"]) {
			return false;
		}
		currentElement = currentElement.parentElement;
	}

	return !currentElement.dataset?.["noDnd"];
};

const SortableDndContainer = <T, K extends { id: UniqueIdentifier }>({
	children,
	items,
	onChange,
	DragOverlayComponent,
	getDragOverlayProps,
}: SortableDndContainerProps<T, K>) => {
	const [activeItem, setActiveItem] = useState<ActiveItem | null>(null);
	const sensors = useSensors(
		useSensor(PointerSensor, {
			activationConstraint: {
				distance: 1,
			},
		}),
		useSensor(KeyboardSensor, {
			coordinateGetter: sortableKeyboardCoordinates,
		}),
	);

	const handleDragStart = useCallback((event: DragStartEvent) => {
		const {
			active: { id, data },
		} = event;

		setActiveItem({
			id,
			index: data.current?.["sortable"].index,
		});
	}, []);

	const handleDragEnd = useCallback(
		(event: DragEndEvent) => {
			const { active, over } = event;

			if (active.id !== over?.id) {
				const oldIndex = items.findIndex((item) => item.id === active.id);
				const newIndex = items.findIndex((item) => item.id === over?.id);
				const newArray = arrayMove(items, oldIndex, newIndex);
				onChange(newArray);
			}

			setActiveItem(null);
		},
		[onChange, items],
	);
	return (
		<DndContext
			collisionDetection={closestCenter}
			onDragEnd={handleDragEnd}
			onDragStart={handleDragStart}
			sensors={sensors}
		>
			<SortableContext items={items}>{children}</SortableContext>
			<DragOverlay
				style={{
					opacity: 0.5,
					cursor: "grabbing",
				}}
			>
				{activeItem ? (
					<DragOverlayComponent {...getDragOverlayProps(activeItem)} />
				) : null}
			</DragOverlay>
		</DndContext>
	);
};

export default SortableDndContainer;

This results in:

/path/to/file/SortableDndContainer.tsx project  INTERNAL  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ⚠ Biome encountered an unusually large amount of types which exceeded the limit of 200,000.
    
    Either you are analyzing very large files (did you make sure to exclude your build/ or dist/ folder?), or you've encountered a bug in Biome.
    
    Please follow these instructions to discover if you are accidentally analyzing large files and what to do about them in the relative guide.
  
  β„Ή In the meantime, you can force this file to be ignored using a `!!` pattern in the files.includes option in your configuration file.
  
  β„Ή Refer to the documentation for more information.
  
  β„Ή If you think this is a bug, please report it and include the following information:
  
  - source code of the file;
  - how the file is imported in the project (by a test file, a dependency, etc.);
  - if and how the file/folder is excluded.
  
  ⚠ Failing to provide this information won't allow the team to fix the issue.
  
  ⚠ This diagnostic was derived from an internal Biome error. Potential bug, please report it if necessary

I applied the source code and it is only ever imported like this:

import type { ActiveItem } from "@riptech/legacy-ui/src/components/DnD/SortableDndContainer";
import SortableDndContainer from "@riptech/legacy-ui/src/components/DnD/SortableDndContainer";

Below is my files.includes:

	"files": {
		"ignoreUnknown": true,
		"includes": [
			"**",
			"!**/_generated",
			"!**/animations/**/*.json",
			"!**/dhlData.json",
			"!switch/**/*.js",
			// `!!` to force ignore from project scanner
			"!!**/dist",
			"!!**/out",
			"!!**/.next",
			"!!**/.vercel",
			"!!**/.serverless",
			"!!**/.esbuild",
			"!!**/coverage"
		]
	},

This file is not matched by those patterns.

Expected result

No warning

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-Type-InferenceArea: type inferenceS-Bug-confirmedStatus: report has been confirmed as a valid bug

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions