glideapps / glideapps/quicktype

JavaScript PropTypes uses PropTypes.any instead of isRequired

Open
#1,561 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
13.9k
Forks
1.2k
Avg merge
8h 53m
Merged PRs (30d)
369

Description

This is quite different from the other type conversions and since I couldn't find an issue raising this concern I'm opening this issue.

## input
```json
{
"type": "object",
"required": [ "disabled" ],
"properties": {
"type": {
"type": "string",
"enum": ["primary", "secondary"]
},
"disabled": { "type": "boolean" }
}
}
```
## current
```js
import PropTypes from "prop-types";

let _Component;
const _Type = PropTypes.oneOfType(['primary', 'secondary']);
_Component = PropTypes.shape({
"disabled": PropTypes.bool,
"type": PropTypes.oneOfType([_Type, PropTypes.any]),
});

export const Component = _Component;
```
## expected
```js
import PropTypes from "prop-types";

let _Component;
_Component = PropTypes.shape({
"disabled": PropTypes.bool.isRequired,
"type": PropTypes.oneOfType(['primary', 'secondary']),
});

export const Component = _Component;
```

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.