Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-json-schema-generator

Package Overview
Dependencies
Maintainers
3
Versions
335
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-json-schema-generator - npm Package Compare versions

Comparing version 2.1.0-next.1 to 2.1.0-next.2

2

dist/package.json
{
"name": "ts-json-schema-generator",
"version": "2.1.0-next.1",
"version": "2.1.0-next.2",
"description": "Generate JSON schema from your Typescript sources",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -11,2 +11,4 @@ import ts from "typescript";

import { StringType } from "../Type/StringType.js";
import { LiteralType } from "../Type/LiteralType.js";
import { isLiteralUnion } from "../TypeFormatter/LiteralUnionTypeFormatter.js";
export class IntersectionNodeParser {

@@ -27,4 +29,10 @@ typeChecker;

}
if (types.length === 2 && types.some((t) => t instanceof StringType) && types.some((t) => isEmptyObject(t))) {
return new StringType(true);
if (types.length === 2 && types.some((t) => isEmptyObject(t))) {
if (types.some((t) => t instanceof StringType)) {
return new StringType(true);
}
const nonObject = types.find((t) => !isEmptyObject(t));
if (nonObject instanceof LiteralType || (nonObject instanceof UnionType && isLiteralUnion(nonObject))) {
return nonObject;
}
}

@@ -31,0 +39,0 @@ return translate(types);

@@ -10,1 +10,2 @@ import { Definition } from "../Schema/Definition.js";

}
export declare function isLiteralUnion(type: UnionType): boolean;

@@ -72,3 +72,3 @@ import { LiteralType } from "../Type/LiteralType.js";

}
function isLiteralUnion(type) {
export function isLiteralUnion(type) {
return flattenTypes(type).every((item) => item instanceof LiteralType || item instanceof NullType || item instanceof StringType);

@@ -75,0 +75,0 @@ }

{
"name": "ts-json-schema-generator",
"version": "2.1.0-next.1",
"version": "2.1.0-next.2",
"description": "Generate JSON schema from your Typescript sources",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -14,2 +14,4 @@ import ts from "typescript";

import { StringType } from "../Type/StringType.js";
import { LiteralType } from "../Type/LiteralType.js";
import { isLiteralUnion } from "../TypeFormatter/LiteralUnionTypeFormatter.js";

@@ -35,4 +37,10 @@ export class IntersectionNodeParser implements SubNodeParser {

// handle autocomplete hacks like `string & {}`
if (types.length === 2 && types.some((t) => t instanceof StringType) && types.some((t) => isEmptyObject(t))) {
return new StringType(true);
if (types.length === 2 && types.some((t) => isEmptyObject(t))) {
if (types.some((t) => t instanceof StringType)) {
return new StringType(true);
}
const nonObject = types.find((t) => !isEmptyObject(t));
if (nonObject instanceof LiteralType || (nonObject instanceof UnionType && isLiteralUnion(nonObject))) {
return nonObject;
}
}

@@ -39,0 +47,0 @@

@@ -86,3 +86,3 @@ import { Definition } from "../Schema/Definition.js";

function isLiteralUnion(type: UnionType): boolean {
export function isLiteralUnion(type: UnionType): boolean {
return flattenTypes(type).every(

@@ -89,0 +89,0 @@ (item) => item instanceof LiteralType || item instanceof NullType || item instanceof StringType,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc