Skip to content

Type error with font weight as a number #11603

@thomas-haufe

Description

@thomas-haufe

Expected behavior

No TypeScript error

Current behavior

Following error:
Type 'number' is not assignable to type 'string | ((ctx: ScriptableCartesianScaleContext, options: AnyObject) => string | null | undefined) | null | undefined'.

Reproducible sample

https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgYQBYENYBoUdgeTBmAgDsBnOAXzgDMoIQ4ByAYzxgDoArc5gbgCwAKBGsy5eBCIkKALlyYYhYhIA8zAEYBXTZoA2AU2YA+OAF5EIuHHKt0R8goTWbcAB7PXbuMRhGvYR8fGEN3GAVmdwBBd2A+LG9g2jIIqyDgnwB3Q2AAc1Q0gE4ABhLEjMyqJJtqyupXOqohUWEAN0w4Vhh3CzgAEwhWbRBDUi48wxgAUSNR8YAhAE8ASX6ACgAiECW0JU2ASjh0SgAJABUAWQAZZHRSDvJZw3mYFo6oOB292D7SQyyilg6267hwLnqMCWYEMkR0eiMzAqPn66Bg6ECmVR6PIUyccAA2jU3BDMj59OhNIZ9JFsScpkjiSi0RjCQhPHAAIw4JYKABMOCgCgAzFRwRyBXBeXBhYKRVQALrIsli4lKpKq+rSVTyODa2TkZWag78IA

Optional extra steps/info to reproduce

No response

Possible solution

Update the type of 'weight' in the 'FontSpec' interface to also accept numbers.

Context

No response

chart.js version

v4.4.0

Browser name and version

No response

Link to your project

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions