Skip to content

Zod error "expected UIEvent" in windowResized parameter validation #8128

@yogan

Description

@yogan

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • p5.strands
  • WebGL
  • DevOps, Build process, Unit testing
  • Internationalization (i18n)
  • Friendly Errors
  • Other (specify if possible)

p5.js version

2.0.5

Web browser and version

Microsoft Edge Version 140.0.3485.94 (Official build) (64-bit), Firefox 143.0 (64-bit)

Operating system

Windows

Steps to reproduce this

Steps:

  1. Have any sketch with a windowResized method
  2. Resize the window
  3. Zod prints this error on the console:
        Zod error object {code: "custom", message: "Expected a UIEvent", …}
        p5.js says:  in windowResized().

Snippet:

	p.windowResized = (event) => {
		console.log({ event })
		p.resizeCanvas(p.windowWidth, p.windowHeight)
	}

The reason is that the event param is documented to be of type UIEvent. However, in most browser, it will just be of type Event.

See: https://developer.mozilla.org/en-US/docs/Web/API/Window/resize_event#event_type

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions