Skip to content

Move plugins to SpreadsheetOptions and getConfig to SpreadsheetInstance in the type definitions - #1806

Open
YuEfSaEDU wants to merge 1 commit into
jspreadsheet:masterfrom
YuEfSaEDU:fix/typings-plugins-placement-1803
Open

YuEfSaEDU wants to merge 1 commit into
jspreadsheet:masterfrom
YuEfSaEDU:fix/typings-plugins-placement-1803

Conversation

@YuEfSaEDU

Copy link
Copy Markdown
Contributor

Both members are verified against the runtime before moving:

  • plugins is read from the top-level spreadsheet options (spreadsheet.setPlugins(options.plugins) in src/utils/factory.js), never from per-worksheet options — so plugins?: Record<string, () => Plugin> belongs in SpreadsheetOptions, not WorksheetOptions.
  • getConfig is bound as spreadsheet.getConfig = getSpreadsheetConfig.bind(spreadsheet); nothing in the runtime ever calls plugin.getConfig — so getConfig: () => SpreadsheetOptions belongs in SpreadsheetInstance, not the Plugin interface.

With this dist/index.d.ts, a usage snippet with plugins at spreadsheet level and spreadsheet.getConfig() type-checks (tsc exit 0); against the previous file it reproduces exactly the two reported errors (TS2353: 'plugins' does not exist in type 'SpreadsheetOptions', TS2551: Property 'getConfig' does not exist on type 'SpreadsheetInstance'). WorksheetInstance.getConfig (worksheet-level) was already correct and is untouched.

Fixes #1803

Move plugins from WorksheetOptions to SpreadsheetOptions, since the
runtime reads it from the top-level options (factory.js:
spreadsheet.setPlugins(options.plugins)).

Move getConfig from the Plugin interface to SpreadsheetInstance, since
the runtime binds it to the spreadsheet instance (factory.js:
spreadsheet.getConfig = getSpreadsheetConfig.bind(spreadsheet)).

Fixes jspreadsheet#1803
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.

ts: Misplacement of getConfig in Plugin interface

1 participant