Typescript: Object literal may only specify known properties, and 'min' does not exist in type
- Dominant language
- JavaScript
- Stars
- 19.4k
- Forks
- 3.1k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 9
Description
**Describe the bug**
If we define a `relation` field with `multiple: true` and `min` or `max` we get the following typescript typings error
```
Object literal may only specify known properties, and 'min' does not exist in type '(CmsFieldBase & CmsFieldRelation) | (CmsFieldBase & CmsFieldMeta)'.
```
**To Reproduce**
1. Have a project using Typescript
2. Have your CMS schema defined in typescript
Sample code:
```ts
import CMS from 'netlify-cms-app';
const local_backend = process.env.NODE_ENV === 'development';
CMS.init({
config: {
local_backend,
load_config_file: false,
backend: {
name: 'git-gateway',
branch: 'main',
},
collections: [
{
name: 'pages',
label: 'Pages',
folder: 'cms/content/pages',
create: false,
slug: '{{slug}}',
fields: [
{
label: 'Fund Types',
name: 'fundTypes',
widget: 'relation',
collection: 'Options',
search_fields: ['label'],
value_field: 'label',
multiple: true,
min: 1, // we get the error here
},
],
},
],
},
});
```
**Expected behavior**
No typescript error should occur, because `min` and `max` are valid relation properties
**Screenshots**
**Applicable Versions:**
- "netlify-cms-app": "^2.15.72",
**CMS configuration**
```ts
import CMS from 'netlify-cms-app';
const local_backend = process.env.NODE_ENV === 'development';
CMS.init({
config: {
local_backend,
load_config_file: false,
backend: {
name: 'git-gateway',
branch: 'main',
},
collections: [
{
name: 'pages',
label: 'Pages',
folder: 'cms/content/pages',
create: false,
slug: '{{slug}}',
fields: [
{
label: 'Fund Types',
name: 'fundTypes',
widget: 'relation',
collection: 'Options',
search_fields: ['label'],
value_field: 'label',
multiple: true,
min: 1, // we get the error here
},
],
},
],
},
});
```
**Additional context**
Contributor guide
Assessment
This issue has not been assessed yet.