Upgrading from v2.19.2 to v2.21.0 getting error "oninput"
I'm upgrading from v2.19.2 to v2.21.0 with the zod plugin and I get this issue:
✔ Generating Zod schemas Error compiling generated code: node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected][email protected]/node_modules/.zenstack/zod/models/Client.schema.ts:45:187 - error TS2552: Cannot find name 'input'. Did you mean 'oninput'?
45 export function refineClient<T>(schema: z.ZodType<T>) { return schema.refine((value: any) => (((value?.status) !== undefined ? ((value?.status != TenantStatus.ARCHIVED)): true) || ((input?.status ?? null) != TenantStatus.ARCHIVED)), { message: "Cannot archive an already archived tenant", }); ~~~~~
../../../../../node_modules/typescript/lib/lib.dom.d.ts:22528:13 22528 declare var oninput: ((this: Window, ev: Event) => any) | null; ~~~~~~~ 'oninput' is declared here. node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected][email protected]/node_modules/.zenstack/zod/models/Device.schema.ts:48:58 - error TS2769: No overload matches this call. Overload 1 of 2, '(def: { recordOnBoot: boolean; stealthMode: boolean; autoNightVision: boolean; nightVisionSensitivity: number; highResVideoSettingsModel: { width: number; height: number; fps: number; codec: number; bitrate: number; segmentTimeMins: number; }; lowResVideoSettingsModel: { ...; }; audioSettingsModel: { ...; }; snapshotSettingsModel: { ...; }; eventSettingsModel: { ...; }; }): ZodDefault<...>', gave the following error. Argument of type '{}' is not assignable to parameter of type '{ recordOnBoot: boolean; stealthMode: boolean; autoNightVision: boolean; nightVisionSensitivity: number; highResVideoSettingsModel: { width: number; height: number; fps: number; codec: number; bitrate: number; segmentTimeMins: number; }; lowResVideoSettingsModel: { ...; }; audioSettingsModel: { ...; }; snapshotSetti...'. Type '{}' is missing the following properties from type '{ recordOnBoot: boolean; stealthMode: boolean; autoNightVision: boolean; nightVisionSensitivity: number; highResVideoSettingsModel: { width: number; height: number; fps: number; codec: number; bitrate: number; segmentTimeMins: number; }; lowResVideoSettingsModel: { ...; }; audioSettingsModel: { ...; }; snapshotSetti...': recordOnBoot, stealthMode, autoNightVision, nightVisionSensitivity, and 5 more. Overload 2 of 2, '(def: () => { recordOnBoot: boolean; stealthMode: boolean; autoNightVision: boolean; nightVisionSensitivity: number; highResVideoSettingsModel: { width: number; height: number; fps: number; codec: number; bitrate: number; segmentTimeMins: number; }; lowResVideoSettingsModel: { ...; }; audioSettingsModel: { ...; }; snapshotSettingsModel: { ...; }; eventSettingsModel: { ...; }; }): ZodDefault<...>', gave the following error. Argument of type '{}' is not assignable to parameter of type '() => { recordOnBoot: boolean; stealthMode: boolean; autoNightVision: boolean; nightVisionSensitivity: number; highResVideoSettingsModel: { width: number; height: number; fps: number; codec: number; bitrate: number; segmentTimeMins: number; }; lowResVideoSettingsModel: { ...; }; audioSettingsModel: { ...; }; snapsho...'. Type '{}' provides no match for the signature '(): { recordOnBoot: boolean; stealthMode: boolean; autoNightVision: boolean; nightVisionSensitivity: number; highResVideoSettingsModel: { width: number; height: number; fps: number; codec: number; bitrate: number; segmentTimeMins: number; }; lowResVideoSettingsModel: { ...; }; audioSettingsModel: { ...; }; snapshotSettingsModel: { ...; }; eventSettingsModel: { ...; }; }'.
48 settings: z.lazy(() => DeviceSettingsSchema).default({}).nullish(), ~~
node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected][email protected]/node_modules/.zenstack/zod/models/Tenant.schema.ts:84:187 - error TS2552: Cannot find name 'input'. Did you mean 'oninput'?
84 export function refineTenant<T>(schema: z.ZodType<T>) { return schema.refine((value: any) => (((value?.status) !== undefined ? ((value?.status != TenantStatus.ARCHIVED)): true) || ((input?.status ?? null) != TenantStatus.ARCHIVED)), { message: "Cannot archive an already archived tenant", }); ~~~~~
../../../../../node_modules/typescript/lib/lib.dom.d.ts:22528:13 22528 declare var oninput: ((this: Window, ev: Event) => any) | null; ~~~~~~~ 'oninput' is declared here. node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected][email protected]/node_modules/.zenstack/zod/models/User.schema.ts:99:186 - error TS2552: Cannot find name 'input'. Did you mean 'oninput'?
99 export function refineUser<T>(schema: z.ZodType<T>) { return schema.refine((value: any) => (((value?.status) !== undefined ? ((value?.status != UserStatus.DEACTIVATED)): true) || ((input?.status ?? null) != UserStatus.DEACTIVATED)), { message: "Cannot deactivate an already deactivated user", }) ~~~~~
../../../../../node_modules/typescript/lib/lib.dom.d.ts:22528:13 22528 declare var oninput: ((this: Window, ev: Event) => any) | null; ~~~~~~~ 'oninput' is declared here.
: Error compiling generated code
Right.... thanks to AI, fixing these issues requires changing these:
@@validate(
- status != ARCHIVED || this.status != ARCHIVED,
+ !(status == ARCHIVED && this.status == ARCHIVED),
"Some error message"
)
}
@@validate(
- status != ARCHIVED || this.status != ARCHIVED,
+ !(status == ARCHIVED && this.status == ARCHIVED),
"some error message"
)
}
@@validate(
- status != DEACTIVATED || this.status != DEACTIVATED,
+ !(status == DEACTIVATED && this.status == DEACTIVATED),
"Cannot deactivate an already deactivated item"
)
Another model
- settings SomeSettings? @json @default("{}")
+ settings SomeSettings? @json
Hope this helps someone else!
Hi @hongkongkiwi , thanks for filing this, but I don't understand why the seamingly unrelated changes fix the issue. Do you have a sharable repro?
I don't understand either but this issue wasn't an issue in previous versions and the changes above fixed it.
Unfortunately it's our internal repo and I cannot share it :/