decaporg / decaporg/decap-cms

type definition does not match code for `registerWidget`?

Open
#5,970 3 comments 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

**Describe the bug**

_I'm willing to submit a PR to address this, but want to be sure I'm not misunderstanding something first..._

The `CMS.registerWidget()` [source](https://github.com/netlify/netlify-cms/blob/dbf2920254fb3682e12463a6df8ded4b94b55be0/packages/netlify-cms-core/src/lib/registry.js#L86) takes four arguments:

```js
export function registerWidget(name, control, preview, schema = {}) { ... }
```

but the [typescript interface exported for it](https://github.com/netlify/netlify-cms/blob/dbf2920254fb3682e12463a6df8ded4b94b55be0/packages/netlify-cms-core/index.d.ts#L565-L569) doesn't include the `schema` argument

```
registerWidget: (
widget: string | CmsWidgetParam,
control?: ComponentType | string,
preview?: ComponentType,
) => void;
```

Additionally, the actual `registerWidget` function checks whether its first argument is an array, and if it is calls its self on each member of the array, but the typescript interface does not recognize this usage as valid.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.