You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
When developing a plugin, new actions aren't accepted by the typechecker.
my-plugin/plugin.tsx
import{MyPluginAction}from'./actions/MyPluginAction';exportconstmyPlugin=definePlugin({name: 'my-plugin',document: {actions: (prev)=>{// shortened version of the error// ❌ impossible to assign type 'string' to type '"delete" | "discardChanges" | "duplicate" | "restore" | "publish" | "unpublish" | undefined'prev.push(MyPluginAction);returnprev;},}});
This will allows users to use declaration merging and add there own action names.
sanity.d.ts
import'sanity'// redeclare the sanity moduledeclare module 'sanity'{exportinterfaceDocumentActionKeys{myPlugin: never}}
Describe alternatives you've considered
I've tried to use declaration merging to rewrite the type of DocumentActionComponent['action'] but that's not how TypeScript works.
Thx, cheers! ✌️
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
When developing a plugin, new actions aren't accepted by the typechecker.
my-plugin/plugin.tsx
my-plugin/actions/MyPluginAction.tsx
I can instead of
DocumentActionComponent
, simply useDocumentActionProps
in theprops
object but I'll simply get a different error.Describe the solution you'd like
Use keys of an interface instead of an union of string literals for
DocumentActionComponent['action']
.packages/sanity/src/core/config/document/actions.ts
This will allows users to use declaration merging and add there own action names.
sanity.d.ts
Describe alternatives you've considered
I've tried to use declaration merging to rewrite the type of
DocumentActionComponent['action']
but that's not how TypeScript works.Thx, cheers! ✌️
The text was updated successfully, but these errors were encountered: