-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
bradzacher
merged 7 commits into
typescript-eslint:main
from
wespickett:fix-JSONSchema4Type
Aug 10, 2023
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f70f8bb
fix: JSONSchema4Type missing Array and Object
wespickett d2bd0e1
fix: cleanup and build fix
wespickett 89c11fc
fix: lint disable line
wespickett 15ce1cb
fix: create and move array/object to a new extended type.
wespickett 4ca3814
Merge branch 'main' into fix-JSONSchema4Type
wespickett dfaafc3
fix: lint error
wespickett 06bbd87
fix: lint error
wespickett File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,23 @@ | |
/** | ||
* @see https://tools.ietf.org/html/draft-zyp-json-schema-04#section-3.5 | ||
*/ | ||
export type JSONSchema4Type = boolean | number | string | null; | ||
export type JSONSchema4Type = | ||
| boolean | ||
| JSONSchema4Array | ||
| JSONSchema4Object | ||
| number | ||
| string | ||
| null; | ||
|
||
// Workaround for infinite type recursion | ||
export interface JSONSchema4Object { | ||
[key: string]: JSONSchema4Type; | ||
} | ||
|
||
// Workaround for infinite type recursion | ||
// https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540 | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface JSONSchema4Array extends Array<JSONSchema4Type> {} | ||
|
||
/** | ||
* Meta schema | ||
|
@@ -51,7 +67,7 @@ | |
| JSONSchema4AnyOfSchema | ||
| JSONSchema4AnySchema | ||
| JSONSchema4ArraySchema | ||
| JSONSchema4BoleanSchema | ||
| JSONSchema4BooleanSchema | ||
| JSONSchema4MultiSchema | ||
| JSONSchema4NullSchema | ||
| JSONSchema4NumberSchema | ||
|
@@ -195,7 +211,7 @@ | |
Omit<JSONSchema4ArraySchema, 'enum' | 'type'>, | ||
Omit<JSONSchema4StringSchema, 'enum' | 'type'>, | ||
Omit<JSONSchema4NumberSchema, 'enum' | 'type'>, | ||
Omit<JSONSchema4BoleanSchema, 'enum' | 'type'>, | ||
Omit<JSONSchema4BooleanSchema, 'enum' | 'type'>, | ||
Omit<JSONSchema4NullSchema, 'enum' | 'type'>, | ||
Omit<JSONSchema4AnySchema, 'enum' | 'type'> { | ||
type: JSONSchema4TypeName[]; | ||
|
@@ -460,7 +476,7 @@ | |
/** | ||
* @see https://json-schema.org/understanding-json-schema/reference/boolean.html | ||
*/ | ||
export interface JSONSchema4BoleanSchema extends JSONSchema4Base { | ||
export interface JSONSchema4BooleanSchema extends JSONSchema4Base { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
type: 'boolean'; | ||
|
||
/** | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 theenum
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.There was a problem hiding this comment.
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 toJSONSchema4DefaultValue
if needed