Skip to content

docs: explain how to type the options of a custom plugin - #1387

Draft
dangreen wants to merge 1 commit into
masterfrom
docs/faq-typescript-plugin-options
Draft

dangreen wants to merge 1 commit into
masterfrom
docs/faq-typescript-plugin-options

Conversation

@dangreen

@dangreen dangreen commented Dec 5, 2026

Copy link
Copy Markdown
Collaborator

Changes

The TypeScript FAQ comes up in searches for PluginOptionsByType, but it did not mention it. A new section, "Options of a custom plugin", shows:

  • the error that TypeScript gives for the options of a plugin it does not know;
  • the module augmentation of PluginOptionsByType, after which options.plugins.centerText type-checks in every chart;
  • the second type parameter of Plugin, which types the options that the hooks of the plugin get.

The section links to the whole plugin in Why doesn't the chart use new plugins? and to the TypeScript typings of plugins in the Chart.js documentation. The description of the page mentions plugin options too.

Checked locally

  • In strict mode with TypeScript 7.0 and Chart.js 4.6, the options of centerText on a <Doughnut> fail with the error quoted in the section, and the code with the augmentation type-checks.
  • The error message wraps, so it does not run under the copy button.
  • The website builds with 0 errors with the whole stack.
  • The squash message passes commitlint.

Stack

  1. docs: explain how to type the options of a custom plugin #1387 ← this PR
  2. docs: call the doughnut chart a donut chart too #1388
  3. docs: keep the sandboxes of the examples out of search results #1389

Merge in this order. When a PR is merged, GitHub retargets the next one to master: rebase it onto master before merging, so that it carries only its own commit.

🤖 Generated with Claude Code

The TypeScript FAQ shows up in searches for PluginOptionsByType but did not cover it. Add the
error that TypeScript gives, the module augmentation and the options type of `Plugin`.
@codecov

codecov Bot commented Dec 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.97%. Comparing base (ca69473) to head (e07556c).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1387   +/-   ##
=======================================
  Coverage   93.97%   93.97%           
=======================================
  Files           3        3           
  Lines          83       83           
  Branches       20       20           
=======================================
  Hits           78       78           
  Misses          3        3           
  Partials        2        2           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant