refactor: replace JSON round-trip with explicit deepStripUndefined utility#7284
Draft
alfonso-noriega wants to merge 1 commit into01-fix-empty-catch-blocksfrom
Draft
refactor: replace JSON round-trip with explicit deepStripUndefined utility#7284alfonso-noriega wants to merge 1 commit into01-fix-empty-catch-blocksfrom
alfonso-noriega wants to merge 1 commit into01-fix-empty-catch-blocksfrom
Conversation
…ility The analytics payload builder used JSON.parse(JSON.stringify(payload)) to strip undefined fields. While functionally correct, the intent is non-obvious — it relies on a side-effect of JSON serialization. Added a dedicated deepStripUndefined() utility to cli-kit's object module with full test coverage, and replaced the JSON round-trip in analytics.ts. This makes the code self-documenting. Note: this is a readability improvement, not a performance one — the operation runs once per CLI command and takes ~2µs either way.
Contributor
Author
|
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. |
This was referenced Apr 14, 2026
Contributor
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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