Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(utils): add to JSONSchema4Type missing Array and Object #7406

Merged
merged 7 commits into from
Aug 10, 2023

Conversation

wespickett
Copy link
Contributor

Updates type to add missing Array and Object

From https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/json-schema/index.d.ts#L30

PR Checklist

Overview

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @wespickett!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

@netlify
Copy link

netlify bot commented Aug 3, 2023

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 06bbd87
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/64d3ae446b9a1c0008aaa104
😎 Deploy Preview https://deploy-preview-7406--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@nx-cloud
Copy link

nx-cloud bot commented Aug 3, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 06bbd87. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 37 targets

Sent with 💌 from NxCloud.

@wespickett wespickett changed the title fix: JSONSchema4Type missing Array and Object fix: add to JSONSchema4Type missing Array and Object Aug 3, 2023
@bradzacher
Copy link
Member

As per our contributing guide please file an issue first so that we can discuss the change and the usecases you're intending to target with it.

Closing pending discussion.

@bradzacher bradzacher closed this Aug 3, 2023
@bradzacher bradzacher reopened this Aug 9, 2023
@bradzacher bradzacher added the bug Something isn't working label Aug 9, 2023
Comment on lines 30 to 31
| JSONSchema4Array
| JSONSchema4Object
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is the best thing for us to add this here because JSONSchema4Type is used in the enum property where arrays and objects are disallowed (slash non-sensical).

So I think it makes sense for us to define a new type JSONSchema4DefaultValue which includes all of the valid default values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bradzacher Updated with a separate type named JSONSchema4TypeExtended, which I thought could be a better name, but can change it to JSONSchema4DefaultValue if needed

@@ -460,7 +476,7 @@ export interface JSONSchema4NumberSchema extends JSONSchema4Base {
/**
* @see https://json-schema.org/understanding-json-schema/reference/boolean.html
*/
export interface JSONSchema4BoleanSchema extends JSONSchema4Base {
export interface JSONSchema4BooleanSchema extends JSONSchema4Base {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

goodcatch

Spelling is hard 😅
Technically this is a breaking change but given it's a cock up I'm fine with doing this here. Given nobody noticed I doubt anyone is using it directly yet!

@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label Aug 9, 2023
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave this as a future exercise - but we can go one step further with this and narrow the default prop for each type. Eg a boolean type schema can only have a boolean default, and an array type schema can only have an array.

Thanks for fixing this!

@bradzacher bradzacher changed the title fix: add to JSONSchema4Type missing Array and Object fix(utils): add to JSONSchema4Type missing Array and Object Aug 10, 2023
@bradzacher bradzacher merged commit 60df0bb into typescript-eslint:main Aug 10, 2023
48 of 49 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
awaiting response Issues waiting for a reply from the OP or another party bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants