-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
Improve JSON types #373
Merged
Merged
Improve JSON types #373
Conversation
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
The JSON types (`Json` and `IsJsonable`) have been improved: * The last part of the `Json` union type was redundant, and has been removed (`Partial<Record<never, never>>`). * A check has been added to `IsJsonable` to prevent the use of numeric keys in objects. In testing I've found this doesn't prevent all cases of this, but it does prevent some. `IsJsonable` playground link with tests: https://www.typescriptlang.org/play?#code/C4TwDgpgBGBOCWBbex4DdoF4oDsCuANgQLABQUFUAPlAEYD29BEAhjmZdbnorRLB0o0AzsAQ4A5mTKhIUACIQAZvBwoIBEADl6wAFLD6OFrWZRsACgsBKcwD4obELZp4cAE2WqI76aVnQAJLCBkYmzAA8ACoOmIIA9PFQAMIAFhAAxgDWUPBKUMDpsNAsxY44ILhGALQAVobGptABwlDFcBDCEDjAPrk4BelQbvBGCUk6vQBcw11Q9PnAeGDMraqD8K0qsKJQGUbuKKMDwvCe1aIQYK2Hogi0eKgYewdHYQQF4J3jUBZd0KlgMBrlNEhIUKk8LQAHT7RDxZAZWD0QxKYDxKJfADKSPgYHRm2EeE68QATABOADMADYABwAYkJxLhiG6wGqABYAKyUrkUnmk6yCADaAFEAB5iFgZYDRAA0Ci8al6mkmoUazDsAF0oBBJd13K1hTgIBhYFrBBQAPxQRJQHQ4OoNcLNL7DNRGKAAdxYW3obncusQ+JAlsoUV1+o8rTgSCOGDD1ttSQACghkE9oJtHBkMldgC7E+GizM7QB5Qr8L2baAZdLZXL5UqwFih8icKARvW9aO-VRKfhQACq1mFFvbnBtdoAgrAWyBWqVoMJIBl4CwCABuKC1PC7OuZHLN1u65isnqfSBFijBdUuiJDu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AXRYBvKALCMEYAFyt2XbkPn8UAXwCwAKB0AzTEgDGwDsijAIbADwAVAHwAKAFaIkqtwEp5ANwQcAEyhRHSgoAHpwqFsrYCgOOHiUYAALaCMEWjAObApTZB0tXW0uS0Y9CiNoAEFg0KgKeToGRgBuQp0dI1y4RIAhOu0wigBCJsx6JnbtIp1QSCgAYTRB4fHJto7i0qYKqqgAEVWJPVJ5Nk4eFQwJlvqBIgoAqRl1luukCB8mLZ0d8sq0AAascKAB+N5TX4lJBlPbQAAaoPkBzyEGmsxhcMBUAAmqCIYc0RjOljdjiAFrIm4bFiGAIQPRcCABEnbWHk-YAdQJ8kcnjQ9gaSBAbK6yDYwpAKywuAaiSootJkSgGSyOSYUAA8gBpOaxRyy7CeaaWNiOCrYOAQE3680ABlt2jNwEcACI3U6XY5hF6DaJ1H7zQJ7UIg67xI0oPaoIHTQbFfKluHHImKIkDinI-JxER5OxMBAADSqnPqdQlgLyAQBksAJhLbpSHDdQjjdtdNYrwSjTZb3aNJYAzGHpjoVWrsuRmKlpAB3OAdw0QOdEyz8lMCT6r1HrzyjpfZjArtcQfmxlNpxLVS8ipN9W-S9NQIGPpMIt-P3GfxIUn9QLkU3pRlmQCFMAFYk2aTVCGAplPjA6YgA
ryanml
approved these changes
Mar 3, 2021
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.
++ lgtm!
MajorLift
pushed a commit
that referenced
this pull request
Oct 11, 2023
The JSON types (`Json` and `IsJsonable`) have been improved: * The last part of the `Json` union type was redundant, and has been removed (`Partial<Record<never, never>>`). * A check has been added to `IsJsonable` to prevent the use of numeric keys in objects. In testing I've found this doesn't prevent all cases of this, but it does prevent some. `IsJsonable` playground link with tests: https://www.typescriptlang.org/play?#code/C4TwDgpgBGBOCWBbex4DdoF4oDsCuANgQLABQUFUAPlAEYD29BEAhjmZdbnorRLB0o0AzsAQ4A5mTKhIUACIQAZvBwoIBEADl6wAFLD6OFrWZRsACgsBKcwD4obELZp4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zGHpjoVWrsuRmKlpAB3OAdw0QOdEyz8lMCT6r1HrzyjpfZjArtcQfmxlNpxLVS8ipN9W-S9NQIGPpMIt-P3GfxIUn9QLkU3pRlmQCFMAFYk2aTVCGAplPjA6YgA
MajorLift
pushed a commit
that referenced
this pull request
Oct 11, 2023
The JSON types (`Json` and `IsJsonable`) have been improved: * The last part of the `Json` union type was redundant, and has been removed (`Partial<Record<never, never>>`). * A check has been added to `IsJsonable` to prevent the use of numeric keys in objects. In testing I've found this doesn't prevent all cases of this, but it does prevent some. `IsJsonable` playground link with tests: https://www.typescriptlang.org/play?#code/C4TwDgpgBGBOCWBbex4DdoF4oDsCuANgQLABQUFUAPlAEYD29BEAhjmZdbnorRLB0o0AzsAQ4A5mTKhIUACIQAZvBwoIBEADl6wAFLD6OFrWZRsACgsBKcwD4obELZp4cAE2WqI76aVnQAJLCBkYmzAA8ACoOmIIA9PFQAMIAFhAAxgDWUPBKUMDpsNAsxY44ILhGALQAVobGptABwlDFcBDCEDjAPrk4BelQbvBGCUk6vQBcw11Q9PnAeGDMraqD8K0qsKJQGUbuKKMDwvCe1aIQYK2Hogi0eKgYewdHYQQF4J3jUBZd0KlgMBrlNEhIUKk8LQAHT7RDxZAZWD0QxKYDxKJfADKSPgYHRm2EeE68QATABOADMADYABwAYkJxLhiG6wGqABYAKyUrkUnmk6yCADaAFEAB5iFgZYDRAA0Ci8al6mkmoUazDsAF0oBBJd13K1hTgIBhYFrBBQAPxQRJQHQ4OoNcLNL7DNRGKAAdxYW3obncusQ+JAlsoUV1+o8rTgSCOGDD1ttSQACghkE9oJtHBkMldgC7E+GizM7QB5Qr8L2baAZdLZXL5UqwFih8icKARvW9aO-VRKfhQACq1mFFvbnBtdoAgrAWyBWqVoMJIBl4CwCABuKC1PC7OuZHLN1u65isnqfSBFijBdUuiJDuxjkvJqAVorVuYHht5ea0WqZMARZ2p0BCqOytwutUJqStUYEmlAAACLS4vi1SgeB8S0Gw1QtEWXZRoaf4ATKRZTkkgTAA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srYCgOOHiUYAALaCMEWjAObApTZB0tXW0uS0Y9CiNoAEFg0KgKeToGRgBuQp0dI1y4RIAhOu0wigBCJsx6JnbtIp1QSCgAYTRB4fHJto7i0qYKqqgAEVWJPVJ5Nk4eFQwJlvqBIgoAqRl1luukCB8mLZ0d8sq0AAascKAB+N5TX4lJBlPbQAAaoPkBzyEGmsxhcMBUAAmqCIYc0RjOljdjiAFrIm4bFiGAIQPRcCABEnbWHk-YAdQJ8kcnjQ9gaSBAbK6yDYwpAKywuAaiSootJkSgGSyOSYUAA8gBpOaxRyy7CeaaWNiOCrYOAQE3680ABlt2jNwEcACI3U6XY5hF6DaJ1H7zQJ7UIg67xI0oPaoIHTQbFfKluHHImKIkDinI-JxER5OxMBAADSqnPqdQlgLyAQBksAJhLbpSHDdQjjdtdNYrwSjTZb3aNJYAzGHpjoVWrsuRmKlpAB3OAdw0QOdEyz8lMCT6r1HrzyjpfZjArtcQfmxlNpxLVS8ipN9W-S9NQIGPpMIt-P3GfxIUn9QLkU3pRlmQCFMAFYk2aTVCGAplPjA6YgA
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The JSON types (
Json
andIsJsonable
) have been improved:Json
union type was redundant, and has been removed (Partial<Record<never, never>>
).IsJsonable
to prevent the use of numeric keys in objects. In testing I've found this doesn't prevent all cases of this, but it does prevent some.IsJsonable
playground link with testsJson
playground link with tests