-
Notifications
You must be signed in to change notification settings - Fork 206
Upgrade Zod to v4 and remove vitest workaround #6179
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
Conversation
- Upgrade Zod from 3.24.1 to 4.0.10 across all packages - Remove custom equality tester from vitest setup that's no longer needed - Update code for Zod 4 compatibility: - Replace deprecated .nonstrict() with .passthrough() - Update error handling to use .issues instead of .errors - Fix TypeScript type compatibility - Update test assertions for Zod 4 error structure Fixes #14413 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Unused files (12)
Unused devDependencies (1)
Unused types (1)
|
…esolved 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Fixed ZodIssue import and interface usage - Updated test expectations for Zod v4 error message format - Fixed type annotations for extension specifications - Handled ZodEffects properly in configuration rewriting - Updated test expectations for scopes field handling All tests now pass and type checking succeeds. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
7c285ed
to
7257549
Compare
Coverage report
Show new covered files 🐣
Show files with reduced coverage 🔻
Test suite run success3103 tests passing in 1322 suites. Report generated by 🧪jest coverage report action from a8e413e |
- Replace generic toThrow() with toThrowErrorMatchingInlineSnapshot() - Restore validation of custom error messages lost in Zod v3 to v4 upgrade - Add 43 inline snapshots across 8 test files - Capture full Zod error structure including codes, paths, and messages - All tests passing with improved error specificity
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/node/notifications-system.d.ts@@ -2,160 +2,60 @@ import { zod } from './schema.js';
declare const NotificationSchema: zod.ZodObject<{
id: zod.ZodString;
message: zod.ZodString;
- type: zod.ZodEnum<["info", "warning", "error"]>;
- frequency: zod.ZodEnum<["always", "once", "once_a_day", "once_a_week"]>;
+ type: zod.ZodEnum<{
+ error: "error";
+ info: "info";
+ warning: "warning";
+ }>;
+ frequency: zod.ZodEnum<{
+ always: "always";
+ once: "once";
+ once_a_day: "once_a_day";
+ once_a_week: "once_a_week";
+ }>;
ownerChannel: zod.ZodString;
cta: zod.ZodOptional<zod.ZodObject<{
label: zod.ZodString;
url: zod.ZodString;
- }, "strip", zod.ZodTypeAny, {
- url: string;
- label: string;
- }, {
- url: string;
- label: string;
- }>>;
+ }, zod.core.>>;
title: zod.ZodOptional<zod.ZodString>;
minVersion: zod.ZodOptional<zod.ZodString>;
maxVersion: zod.ZodOptional<zod.ZodString>;
minDate: zod.ZodOptional<zod.ZodString>;
maxDate: zod.ZodOptional<zod.ZodString>;
- commands: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
+ commands: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
surface: zod.ZodOptional<zod.ZodString>;
-}, "strip", zod.ZodTypeAny, {
- id: string;
- type: "error" | "info" | "warning";
- message: string;
- frequency: "always" | "once" | "once_a_day" | "once_a_week";
- ownerChannel: string;
- title?: string | undefined;
- cta?: {
- url: string;
- label: string;
- } | undefined;
- minVersion?: string | undefined;
- maxVersion?: string | undefined;
- minDate?: string | undefined;
- maxDate?: string | undefined;
- commands?: string[] | undefined;
- surface?: string | undefined;
-}, {
- id: string;
- type: "error" | "info" | "warning";
- message: string;
- frequency: "always" | "once" | "once_a_day" | "once_a_week";
- ownerChannel: string;
- title?: string | undefined;
- cta?: {
- url: string;
- label: string;
- } | undefined;
- minVersion?: string | undefined;
- maxVersion?: string | undefined;
- minDate?: string | undefined;
- maxDate?: string | undefined;
- commands?: string[] | undefined;
- surface?: string | undefined;
-}>;
+}, zod.core.>;
export type Notification = zod.infer<typeof NotificationSchema>;
declare const NotificationsSchema: zod.ZodObject<{
notifications: zod.ZodArray<zod.ZodObject<{
id: zod.ZodString;
message: zod.ZodString;
- type: zod.ZodEnum<["info", "warning", "error"]>;
- frequency: zod.ZodEnum<["always", "once", "once_a_day", "once_a_week"]>;
+ type: zod.ZodEnum<{
+ error: "error";
+ info: "info";
+ warning: "warning";
+ }>;
+ frequency: zod.ZodEnum<{
+ always: "always";
+ once: "once";
+ once_a_day: "once_a_day";
+ once_a_week: "once_a_week";
+ }>;
ownerChannel: zod.ZodString;
cta: zod.ZodOptional<zod.ZodObject<{
label: zod.ZodString;
url: zod.ZodString;
- }, "strip", zod.ZodTypeAny, {
- url: string;
- label: string;
- }, {
- url: string;
- label: string;
- }>>;
+ }, zod.core.>>;
title: zod.ZodOptional<zod.ZodString>;
minVersion: zod.ZodOptional<zod.ZodString>;
maxVersion: zod.ZodOptional<zod.ZodString>;
minDate: zod.ZodOptional<zod.ZodString>;
maxDate: zod.ZodOptional<zod.ZodString>;
- commands: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
+ commands: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
surface: zod.ZodOptional<zod.ZodString>;
- }, "strip", zod.ZodTypeAny, {
- id: string;
- type: "error" | "info" | "warning";
- message: string;
- frequency: "always" | "once" | "once_a_day" | "once_a_week";
- ownerChannel: string;
- title?: string | undefined;
- cta?: {
- url: string;
- label: string;
- } | undefined;
- minVersion?: string | undefined;
- maxVersion?: string | undefined;
- minDate?: string | undefined;
- maxDate?: string | undefined;
- commands?: string[] | undefined;
- surface?: string | undefined;
- }, {
- id: string;
- type: "error" | "info" | "warning";
- message: string;
- frequency: "always" | "once" | "once_a_day" | "once_a_week";
- ownerChannel: string;
- title?: string | undefined;
- cta?: {
- url: string;
- label: string;
- } | undefined;
- minVersion?: string | undefined;
- maxVersion?: string | undefined;
- minDate?: string | undefined;
- maxDate?: string | undefined;
- commands?: string[] | undefined;
- surface?: string | undefined;
- }>, "many">;
-}, "strip", zod.ZodTypeAny, {
- notifications: {
- id: string;
- type: "error" | "info" | "warning";
- message: string;
- frequency: "always" | "once" | "once_a_day" | "once_a_week";
- ownerChannel: string;
- title?: string | undefined;
- cta?: {
- url: string;
- label: string;
- } | undefined;
- minVersion?: string | undefined;
- maxVersion?: string | undefined;
- minDate?: string | undefined;
- maxDate?: string | undefined;
- commands?: string[] | undefined;
- surface?: string | undefined;
- }[];
-}, {
- notifications: {
- id: string;
- type: "error" | "info" | "warning";
- message: string;
- frequency: "always" | "once" | "once_a_day" | "once_a_week";
- ownerChannel: string;
- title?: string | undefined;
- cta?: {
- url: string;
- label: string;
- } | undefined;
- minVersion?: string | undefined;
- maxVersion?: string | undefined;
- minDate?: string | undefined;
- maxDate?: string | undefined;
- commands?: string[] | undefined;
- surface?: string | undefined;
- }[];
-}>;
+ }, zod.core.>>;
+}, zod.core.>;
export type Notifications = zod.infer<typeof NotificationsSchema>;
/**
* Shows notifications to the user if they meet the criteria specified in the notifications.json file.
packages/cli-kit/dist/public/node/schema.d.ts@@ -3,7 +3,9 @@ export { z as zod } from 'zod';
/**
* Type alias for a zod object schema that produces a given shape once parsed.
*/
-export type ZodObjectOf<T> = ZodObject<any, any, any, T>;
+export type ZodObjectOf<T> = ZodObject<{
+ [K in keyof T]: z.ZodType<T[K]>;
+}>;
/**
* Returns a new schema that is the same as the input schema, but with all nested schemas set to strict.
*
@@ -17,7 +19,7 @@ export declare function deepStrict<T>(schema: T): T;
* @param errors - The list of zod errors.
* @returns The human-readable string.
*/
-export declare function errorsToString(errors: z.ZodIssueBase[]): string;
+export declare function errorsToString(errors: z.ZodIssue[]): string;
/**
* A neutral type for the result of a parsing/validation operation.
*
@@ -31,5 +33,5 @@ export type ParseConfigurationResult<TConfiguration> = {
} | {
state: 'error';
data: undefined;
- errors: Pick<z.ZodIssueBase, 'path' | 'message'>[];
+ errors: Pick<z.ZodIssue, 'path' | 'message'>[];
};
\ No newline at end of file
packages/cli-kit/dist/private/node/session/schema.d.ts@@ -5,38 +5,18 @@ import { zod } from '../../../public/node/schema.js';
declare const IdentityTokenSchema: zod.ZodObject<{
accessToken: zod.ZodString;
refreshToken: zod.ZodString;
- expiresAt: zod.ZodEffects<zod.ZodDate, Date, unknown>;
- scopes: zod.ZodArray<zod.ZodString, "many">;
+ expiresAt: zod.ZodPipe<zod.ZodTransform<Date | null, unknown>, zod.ZodDate>;
+ scopes: zod.ZodArray<zod.ZodString>;
userId: zod.ZodString;
-}, "strip", zod.ZodTypeAny, {
- accessToken: string;
- refreshToken: string;
- scopes: string[];
- expiresAt: Date;
- userId: string;
-}, {
- accessToken: string;
- refreshToken: string;
- scopes: string[];
- userId: string;
- expiresAt?: unknown;
-}>;
+}, zod.core.>;
/**
* The schema represents an application token.
*/
declare const ApplicationTokenSchema: zod.ZodObject<{
accessToken: zod.ZodString;
- expiresAt: zod.ZodEffects<zod.ZodDate, Date, unknown>;
- scopes: zod.ZodArray<zod.ZodString, "many">;
-}, "strip", zod.ZodTypeAny, {
- accessToken: string;
- scopes: string[];
- expiresAt: Date;
-}, {
- accessToken: string;
- scopes: string[];
- expiresAt?: unknown;
-}>;
+ expiresAt: zod.ZodPipe<zod.ZodTransform<Date | null, unknown>, zod.ZodDate>;
+ scopes: zod.ZodArray<zod.ZodString>;
+}, zod.core.>;
/**
* This schema represents the format of the session
* that we cache in the system to avoid unnecessary
@@ -45,295 +25,20 @@ declare const ApplicationTokenSchema: zod.ZodObject<{
* @example
*
*/
-export declare const SessionSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{
- /**
- * It contains the identity token. Before usint it, we exchange it
- * to get a token that we can use with different applications. The exchanged
- * tokens for the applications are stored under applications.
- */
+export declare const SessionSchema: zod.ZodObject<{}, zod.core.<zod.ZodObject<{
identity: zod.ZodObject<{
accessToken: zod.ZodString;
refreshToken: zod.ZodString;
- expiresAt: zod.ZodEffects<zod.ZodDate, Date, unknown>;
- scopes: zod.ZodArray<zod.ZodString, "many">;
+ expiresAt: zod.ZodPipe<zod.ZodTransform<Date | null, unknown>, zod.ZodDate>;
+ scopes: zod.ZodArray<zod.ZodString>;
userId: zod.ZodString;
- }, "strip", zod.ZodTypeAny, {
- accessToken: string;
- refreshToken: string;
- scopes: string[];
- expiresAt: Date;
- userId: string;
- }, {
- accessToken: string;
- refreshToken: string;
- scopes: string[];
- userId: string;
- expiresAt?: unknown;
- }>;
- /**
- * It contains exchanged tokens for the applications the CLI
- * authenticates with. Tokens are scoped under the fqdn of the applications.
- */
- applications: zod.ZodObject<{}, "strip", zod.ZodObject<{
+ }, zod.core.>;
+ applications: zod.ZodObject<{}, zod.core.<zod.ZodObject<{
accessToken: zod.ZodString;
- expiresAt: zod.ZodEffects<zod.ZodDate, Date, unknown>;
- scopes: zod.ZodArray<zod.ZodString, "many">;
- }, "strip", zod.ZodTypeAny, {
- accessToken: string;
- scopes: string[];
- expiresAt: Date;
- }, {
- accessToken: string;
- scopes: string[];
- expiresAt?: unknown;
- }>, zod.objectOutputType<{}, zod.ZodObject<{
- accessToken: zod.ZodString;
- expiresAt: zod.ZodEffects<zod.ZodDate, Date, unknown>;
- scopes: zod.ZodArray<zod.ZodString, "many">;
- }, "strip", zod.ZodTypeAny, {
- accessToken: string;
- scopes: string[];
- expiresAt: Date;
- }, {
- accessToken: string;
- scopes: string[];
- expiresAt?: unknown;
- }>, "strip">, zod.objectInputType<{}, zod.ZodObject<{
- accessToken: zod.ZodString;
- expiresAt: zod.ZodEffects<zod.ZodDate, Date, unknown>;
- scopes: zod.ZodArray<zod.ZodString, "many">;
- }, "strip", zod.ZodTypeAny, {
- accessToken: string;
- scopes: string[];
- expiresAt: Date;
- }, {
- accessToken: string;
- scopes: string[];
- expiresAt?: unknown;
- }>, "strip">>;
-}, "strip", zod.ZodTypeAny, {
- identity: {
- accessToken: string;
- refreshToken: string;
- scopes: string[];
- expiresAt: Date;
- userId: string;
- };
- applications: {} & {
- [k: string]: {
- accessToken: string;
- scopes: string[];
- expiresAt: Date;
- };
- };
-}, {
- identity: {
- accessToken: string;
- refreshToken: string;
- scopes: string[];
- userId: string;
- expiresAt?: unknown;
- };
- applications: {} & {
- [k: string]: {
- accessToken: string;
- scopes: string[];
- expiresAt?: unknown;
- };
- };
-}>, zod.objectOutputType<{}, zod.ZodObject<{
- /**
- * It contains the identity token. Before usint it, we exchange it
- * to get a token that we can use with different applications. The exchanged
- * tokens for the applications are stored under applications.
- */
- identity: zod.ZodObject<{
- accessToken: zod.ZodString;
- refreshToken: zod.ZodString;
- expiresAt: zod.ZodEffects<zod.ZodDate, Date, unknown>;
- scopes: zod.ZodArray<zod.ZodString, "many">;
- userId: zod.ZodString;
- }, "strip", zod.ZodTypeAny, {
- accessToken: string;
- refreshToken: string;
- scopes: string[];
- expiresAt: Date;
- userId: string;
- }, {
- accessToken: string;
- refreshToken: string;
- scopes: string[];
- userId: string;
- expiresAt?: unknown;
- }>;
- /**
- * It contains exchanged tokens for the applications the CLI
- * authenticates with. Tokens are scoped under the fqdn of the applications.
- */
- applications: zod.ZodObject<{}, "strip", zod.ZodObject<{
- accessToken: zod.ZodString;
- expiresAt: zod.ZodEffects<zod.ZodDate, Date, unknown>;
- scopes: zod.ZodArray<zod.ZodString, "many">;
- }, "strip", zod.ZodTypeAny, {
- accessToken: string;
- scopes: string[];
- expiresAt: Date;
- }, {
- accessToken: string;
- scopes: string[];
- expiresAt?: unknown;
- }>, zod.objectOutputType<{}, zod.ZodObject<{
- accessToken: zod.ZodString;
- expiresAt: zod.ZodEffects<zod.ZodDate, Date, unknown>;
- scopes: zod.ZodArray<zod.ZodString, "many">;
- }, "strip", zod.ZodTypeAny, {
- accessToken: string;
- scopes: string[];
- expiresAt: Date;
- }, {
- accessToken: string;
- scopes: string[];
- expiresAt?: unknown;
- }>, "strip">, zod.objectInputType<{}, zod.ZodObject<{
- accessToken: zod.ZodString;
- expiresAt: zod.ZodEffects<zod.ZodDate, Date, unknown>;
- scopes: zod.ZodArray<zod.ZodString, "many">;
- }, "strip", zod.ZodTypeAny, {
- accessToken: string;
- scopes: string[];
- expiresAt: Date;
- }, {
- accessToken: string;
- scopes: string[];
- expiresAt?: unknown;
- }>, "strip">>;
-}, "strip", zod.ZodTypeAny, {
- identity: {
- accessToken: string;
- refreshToken: string;
- scopes: string[];
- expiresAt: Date;
- userId: string;
- };
- applications: {} & {
- [k: string]: {
- accessToken: string;
- scopes: string[];
- expiresAt: Date;
- };
- };
-}, {
- identity: {
- accessToken: string;
- refreshToken: string;
- scopes: string[];
- userId: string;
- expiresAt?: unknown;
- };
- applications: {} & {
- [k: string]: {
- accessToken: string;
- scopes: string[];
- expiresAt?: unknown;
- };
- };
-}>, "strip">, zod.objectInputType<{}, zod.ZodObject<{
- /**
- * It contains the identity token. Before usint it, we exchange it
- * to get a token that we can use with different applications. The exchanged
- * tokens for the applications are stored under applications.
- */
- identity: zod.ZodObject<{
- accessToken: zod.ZodString;
- refreshToken: zod.ZodString;
- expiresAt: zod.ZodEffects<zod.ZodDate, Date, unknown>;
- scopes: zod.ZodArray<zod.ZodString, "many">;
- userId: zod.ZodString;
- }, "strip", zod.ZodTypeAny, {
- accessToken: string;
- refreshToken: string;
- scopes: string[];
- expiresAt: Date;
- userId: string;
- }, {
- accessToken: string;
- refreshToken: string;
- scopes: string[];
- userId: string;
- expiresAt?: unknown;
- }>;
- /**
- * It contains exchanged tokens for the applications the CLI
- * authenticates with. Tokens are scoped under the fqdn of the applications.
- */
- applications: zod.ZodObject<{}, "strip", zod.ZodObject<{
- accessToken: zod.ZodString;
- expiresAt: zod.ZodEffects<zod.ZodDate, Date, unknown>;
- scopes: zod.ZodArray<zod.ZodString, "many">;
- }, "strip", zod.ZodTypeAny, {
- accessToken: string;
- scopes: string[];
- expiresAt: Date;
- }, {
- accessToken: string;
- scopes: string[];
- expiresAt?: unknown;
- }>, zod.objectOutputType<{}, zod.ZodObject<{
- accessToken: zod.ZodString;
- expiresAt: zod.ZodEffects<zod.ZodDate, Date, unknown>;
- scopes: zod.ZodArray<zod.ZodString, "many">;
- }, "strip", zod.ZodTypeAny, {
- accessToken: string;
- scopes: string[];
- expiresAt: Date;
- }, {
- accessToken: string;
- scopes: string[];
- expiresAt?: unknown;
- }>, "strip">, zod.objectInputType<{}, zod.ZodObject<{
- accessToken: zod.ZodString;
- expiresAt: zod.ZodEffects<zod.ZodDate, Date, unknown>;
- scopes: zod.ZodArray<zod.ZodString, "many">;
- }, "strip", zod.ZodTypeAny, {
- accessToken: string;
- scopes: string[];
- expiresAt: Date;
- }, {
- accessToken: string;
- scopes: string[];
- expiresAt?: unknown;
- }>, "strip">>;
-}, "strip", zod.ZodTypeAny, {
- identity: {
- accessToken: string;
- refreshToken: string;
- scopes: string[];
- expiresAt: Date;
- userId: string;
- };
- applications: {} & {
- [k: string]: {
- accessToken: string;
- scopes: string[];
- expiresAt: Date;
- };
- };
-}, {
- identity: {
- accessToken: string;
- refreshToken: string;
- scopes: string[];
- userId: string;
- expiresAt?: unknown;
- };
- applications: {} & {
- [k: string]: {
- accessToken: string;
- scopes: string[];
- expiresAt?: unknown;
- };
- };
-}>, "strip">>;
+ expiresAt: zod.ZodPipe<zod.ZodTransform<Date | null, unknown>, zod.ZodDate>;
+ scopes: zod.ZodArray<zod.ZodString>;
+ }, zod.core.>>>;
+}, zod.core.>>>;
export type Session = zod.infer<typeof SessionSchema>;
export type IdentityToken = zod.infer<typeof IdentityTokenSchema>;
export type ApplicationToken = zod.infer<typeof ApplicationTokenSchema>;
|
This PR seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. |
Summary
Changes
.nonstrict()
with.passthrough()
Related Issue
Fixes #14413
Testing
Next Steps