refactor: replace unsafe 'as any' casts with proper types in cli-kit#7287
refactor: replace unsafe 'as any' casts with proper types in cli-kit#7287alfonso-noriega wants to merge 1 commit into
Conversation
Replaced 5 'as any' casts in production code with type-safe alternatives: - error.ts: Use Record<string, unknown> + typeof guards instead of 'as any' - cli.ts: Access PackageJson.name directly (already typed as optional) - metadata.ts: Use PerformanceMeasureOptions instead of 'as any' - plugins.ts: Use the actual generic return type instead of 'as any' Each change removes an eslint-disable comment and makes the code safer against runtime type mismatches.
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Differences in type declarationsWe detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:
New type declarationsWe found no new type declarations in this PR Existing type declarationspackages/cli-kit/dist/public/common/object.d.ts@@ -84,4 +84,12 @@ export declare function isEmpty(object: object): boolean;
* @param object - The object whose undefined will be deleted.
* @returns A copy of the object with the undefined elements deleted.
*/
-export declare function compact(object: object): object;
\ No newline at end of file
+export declare function compact(object: object): object;
+/**
+ * Recursively removes properties with values from an object.
+ * Arrays are traversed but not filtered. Non-object values are returned as-is.
+ *
+ * @param value - The value to strip undefined fields from.
+ * @returns A deep copy of the value with all undefined-valued keys removed.
+ */
+export declare function deepStripUndefined<T>(value: T): T;
\ No newline at end of file
packages/cli-kit/dist/public/node/node-package-manager.d.ts@@ -60,10 +60,6 @@ export declare class FindUpAndReadPackageJsonNotFoundError extends BugError {
export declare function packageManagerFromUserAgent(env?: NodeJS.ProcessEnv): PackageManager;
/**
* Returns the dependency manager used in a directory.
- * Walks upward from so workspace packages (e.g. )
- * still resolve to the repo root lockfile ().
- * If no lockfile is found, it falls back to the package manager from the user agent.
- * If the package manager from the user agent is unknown, it returns 'npm'.
* @param fromDirectory - The starting directory
* @returns The dependency manager
*/
packages/cli-kit/dist/public/node/upgrade.d.ts@@ -28,14 +28,11 @@ export declare function versionToAutoUpgrade(): string | undefined;
export declare function warnIfUpgradeAvailable(): Promise<void>;
/**
* Generates a message to remind the user to update the CLI.
- * For major version bumps, appends a link to the GitHub release notes so users
- * can review breaking changes before deciding to upgrade.
*
* @param version - The version to update to.
- * @param isMajor - Whether the version bump is a major version change.
* @returns The message to remind the user to update the CLI.
*/
-export declare function getOutputUpdateCLIReminder(version: string, isMajor?: boolean): string;
+export declare function getOutputUpdateCLIReminder(version: string): string;
/**
* Prompts the user to enable or disable automatic upgrades, then persists their choice.
*
packages/cli-kit/dist/private/node/ui/components/DangerousConfirmationPrompt.d.ts@@ -1,4 +1,3 @@
-import { InlineToken, TokenItem } from './TokenizedText.js';
import { InfoTableProps } from './Prompts/InfoTable.js';
import { AbortSignal } from '../../../../public/node/abort.js';
import { FunctionComponent } from 'react';
@@ -6,7 +5,6 @@ export interface DangerousConfirmationPromptProps {
message: string;
confirmation: string;
infoTable?: InfoTableProps['table'];
- warningItem?: TokenItem<InlineToken>;
onSubmit: (value: boolean) => void;
abortSignal?: AbortSignal;
}
|
|
This PR seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. |

WHY are these changes introduced?
Fixes #0000
WHAT is this pull request doing?
How to test your changes?
Post-release steps
Checklist
pnpm changeset add