Skip to content

Conversation

@Infinite-Null
Copy link
Contributor

@Infinite-Null Infinite-Null commented Jun 25, 2025

What?

Part of: #67691
Migrating the packages/list-reusable-blocks package to TypeScript.

Why?

Type safety.

Testing Instructions

Typecheck and unit tests.

@t-hamano t-hamano mentioned this pull request Jun 24, 2025
40 tasks
@t-hamano t-hamano added the [Type] Code Quality Issues or PRs that relate to code quality label Jun 25, 2025
@Infinite-Null Infinite-Null marked this pull request as ready for review June 26, 2025 14:22
@github-actions
Copy link

github-actions bot commented Jun 26, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Infinite-Null <ankitkumarshah@git.wordpress.org>
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Infinite-Null Infinite-Null changed the title [WIP] Migrate packages/list-reusable-blocks package to TypeScript TypeScript: Migrate packages/list-reusable-blocks package to TypeScript Jun 26, 2025
@manzoorwanijk
Copy link
Member

Can we update this branch from trunk and then we can review it?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the packages/list-reusable-blocks package from JavaScript to TypeScript, adding type annotations and creating type definitions to improve type safety.

Changes:

  • Added TypeScript configuration files for the package and root project
  • Created type definitions for components and data structures
  • Migrated all source files (.js to .tsx/.ts) with type annotations

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tsconfig.json Added reference to the list-reusable-blocks package
packages/list-reusable-blocks/tsconfig.json Created TypeScript configuration for the package
packages/list-reusable-blocks/src/utils/types.ts Added type definitions for components and data structures
packages/list-reusable-blocks/src/utils/import.ts Migrated to TypeScript with type annotations
packages/list-reusable-blocks/src/utils/file.ts Migrated to TypeScript with type annotations
packages/list-reusable-blocks/src/utils/export.ts Migrated to TypeScript with type annotations
packages/list-reusable-blocks/src/index.tsx Migrated to TypeScript with proper event typing
packages/list-reusable-blocks/src/components/import-form/index.tsx Migrated to TypeScript with React event types
packages/list-reusable-blocks/src/components/import-dropdown/index.tsx Migrated to TypeScript with proper prop typing
Comments suppressed due to low confidence (2)

packages/list-reusable-blocks/src/components/import-form/index.tsx:35

  • Using any type for the parameter defeats the purpose of TypeScript migration. The parameter should be typed as ReusableBlock based on the return type of importReusableBlock.
    packages/list-reusable-blocks/src/components/import-form/index.tsx:43
  • Using any type for the errors parameter defeats the purpose of TypeScript migration. Consider defining a proper error type or using Error type.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

raw: string;
};
wp_pattern_sync_status: string;
[ key: string ]: any;
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

Using index signatures [ key: string ]: any weakens type safety. Consider defining specific properties or using a more restrictive approach if these extra properties are truly needed.

Copilot uses AI. Check for mistakes.
title: string;
content: string;
syncStatus?: string;
[ key: string ]: any;
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

Using index signatures [ key: string ]: any weakens type safety. Consider defining specific properties or using a more restrictive approach if these extra properties are truly needed.

Suggested change
[ key: string ]: any;
[ key: string ]: unknown;

Copilot uses AI. Check for mistakes.
rendered: string;
};
status: string;
[ key: string ]: any;
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

Using index signatures [ key: string ]: any weakens type safety. Consider defining specific properties or using a more restrictive approach if these extra properties are truly needed.

Suggested change
[ key: string ]: any;
[ key: string ]: unknown;

Copilot uses AI. Check for mistakes.
Comment on lines +2 to +7
onUpload: ( data: any ) => void;
}

interface ImportFormProps {
instanceId: string | number;
onUpload: ( reusableBlock: any ) => void;
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

The type definitions use any type which defeats the purpose of TypeScript migration. The onUpload callback should have a properly typed parameter instead of any.

Suggested change
onUpload: ( data: any ) => void;
}
interface ImportFormProps {
instanceId: string | number;
onUpload: ( reusableBlock: any ) => void;
onUpload: ( data: ReusableBlockData ) => void;
}
interface ImportFormProps {
instanceId: string | number;
onUpload: ( reusableBlock: ReusableBlockData ) => void;

Copilot uses AI. Check for mistakes.
Comment on lines +2 to +7
onUpload: ( data: any ) => void;
}

interface ImportFormProps {
instanceId: string | number;
onUpload: ( reusableBlock: any ) => void;
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

The type definitions use any type which defeats the purpose of TypeScript migration. The onUpload callback should have a properly typed parameter instead of any.

Suggested change
onUpload: ( data: any ) => void;
}
interface ImportFormProps {
instanceId: string | number;
onUpload: ( reusableBlock: any ) => void;
onUpload: ( data: ReusableBlockData ) => void;
}
interface ImportFormProps {
instanceId: string | number;
onUpload: ( reusableBlock: ReusableBlockData ) => void;

Copilot uses AI. Check for mistakes.

interface PostType {
rest_base: string;
[ key: string ]: any;
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

Using index signatures [ key: string ]: any weakens type safety. Consider defining specific properties or using a more restrictive approach if these extra properties are truly needed.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants