Skip to content

[p5.js 2.0 Bug Report]: setup() return type should also allow Promise<void> #8662

@FunctionDJ

Description

@FunctionDJ

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

p5.js version

2.2.2

Web browser and version

not applicable

Operating system

not applicable

Steps to reproduce this

Steps:

  1. Setup https://typescript-eslint.io/
  2. Use tseslint.configs.strictTypeChecked base config or enable the typescript-eslint/no-misused-promises rule

Snippet:

new p5((p) => {
  p.setup = async () => { // eslint error: Promise-returning function provided to variable where a void return was expected
    await loadImage("/img.jpg")
  }
}

Suggestion:

i think the fix would just be to add this JSDoc line to setup():

 * @return {void|Promise<void>}

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