ts-json-schema-generator
Advanced tools
Comparing version 1.5.1 to 1.5.2--canary.1910.50ff2b2.0
@@ -13,2 +13,3 @@ "use strict"; | ||
const EnumTypeFormatter_1 = require("../src/TypeFormatter/EnumTypeFormatter"); | ||
const FunctionTypeFormatter_1 = require("../src/TypeFormatter/FunctionTypeFormatter"); | ||
const HiddenTypeFormatter_1 = require("../src/TypeFormatter/HiddenTypeFormatter"); | ||
@@ -61,2 +62,3 @@ const IntersectionTypeFormatter_1 = require("../src/TypeFormatter/IntersectionTypeFormatter"); | ||
.addTypeFormatter(new LiteralUnionTypeFormatter_1.LiteralUnionTypeFormatter()) | ||
.addTypeFormatter(new FunctionTypeFormatter_1.FunctionTypeFormatter()) | ||
.addTypeFormatter(new OptionalTypeFormatter_1.OptionalTypeFormatter(circularReferenceTypeFormatter)) | ||
@@ -63,0 +65,0 @@ .addTypeFormatter(new RestTypeFormatter_1.RestTypeFormatter(circularReferenceTypeFormatter)) |
{ | ||
"name": "ts-json-schema-generator", | ||
"version": "1.5.1", | ||
"version": "1.5.2--canary.1910.50ff2b2.0", | ||
"description": "Generate JSON schema from your Typescript sources", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -12,3 +12,4 @@ "use strict"; | ||
const LiteralType_1 = require("../Type/LiteralType"); | ||
const UnknownType_1 = require("../Type/UnknownType"); | ||
const NeverType_1 = require("../Type/NeverType"); | ||
const FunctionType_1 = require("../Type/FunctionType"); | ||
class TypeofNodeParser { | ||
@@ -29,3 +30,9 @@ constructor(typeChecker, childNodeParser) { | ||
const valueDec = symbol.valueDeclaration; | ||
if (typescript_1.default.isEnumDeclaration(valueDec)) { | ||
if (!valueDec) { | ||
if (symbol.name === "globalThis") { | ||
return new NeverType_1.NeverType(); | ||
} | ||
throw new LogicError_1.LogicError(`No value declaration found for symbol "${symbol.name}"`); | ||
} | ||
else if (typescript_1.default.isEnumDeclaration(valueDec)) { | ||
return this.createObjectFromEnum(valueDec, context, reference); | ||
@@ -51,3 +58,3 @@ } | ||
else if (valueDec.kind === typescript_1.default.SyntaxKind.FunctionDeclaration) { | ||
return new UnknownType_1.UnknownType(`(${valueDec.parameters.map((p) => p.getFullText()).join(",")}) -> ${(_a = valueDec.type) === null || _a === void 0 ? void 0 : _a.getFullText()}`); | ||
return new FunctionType_1.FunctionType(`(${valueDec.parameters.map((p) => p.getFullText()).join(",")}) ->${(_a = valueDec.type) === null || _a === void 0 ? void 0 : _a.getFullText()}`); | ||
} | ||
@@ -54,0 +61,0 @@ throw new LogicError_1.LogicError(`Invalid type query "${valueDec.getFullText()}" (ts.SyntaxKind = ${valueDec.kind})`); |
import { BaseType } from "./BaseType"; | ||
export declare class FunctionType extends BaseType { | ||
private comment?; | ||
constructor(comment?: string | undefined); | ||
getId(): string; | ||
getComment(): string | undefined; | ||
} |
@@ -6,7 +6,14 @@ "use strict"; | ||
class FunctionType extends BaseType_1.BaseType { | ||
constructor(comment) { | ||
super(); | ||
this.comment = comment; | ||
} | ||
getId() { | ||
return "function"; | ||
} | ||
getComment() { | ||
return this.comment; | ||
} | ||
} | ||
exports.FunctionType = FunctionType; | ||
//# sourceMappingURL=FunctionType.js.map |
import { BaseType } from "./BaseType"; | ||
export declare class UnknownType extends BaseType { | ||
private comment?; | ||
constructor(comment?: string | undefined); | ||
constructor(); | ||
getId(): string; | ||
getComment(): string | undefined; | ||
} |
@@ -6,5 +6,4 @@ "use strict"; | ||
class UnknownType extends BaseType_1.BaseType { | ||
constructor(comment) { | ||
constructor() { | ||
super(); | ||
this.comment = comment; | ||
} | ||
@@ -14,7 +13,4 @@ getId() { | ||
} | ||
getComment() { | ||
return this.comment; | ||
} | ||
} | ||
exports.UnknownType = UnknownType; | ||
//# sourceMappingURL=UnknownType.js.map |
@@ -10,5 +10,3 @@ "use strict"; | ||
getDefinition(type) { | ||
return { | ||
$comment: type.getComment(), | ||
}; | ||
return {}; | ||
} | ||
@@ -15,0 +13,0 @@ getChildren(type) { |
@@ -13,2 +13,3 @@ import { ChainTypeFormatter } from "../src/ChainTypeFormatter"; | ||
import { EnumTypeFormatter } from "../src/TypeFormatter/EnumTypeFormatter"; | ||
import { FunctionTypeFormatter } from "../src/TypeFormatter/FunctionTypeFormatter"; | ||
import { HiddenTypeFormatter } from "../src/TypeFormatter/HiddenTypeFormatter"; | ||
@@ -74,2 +75,4 @@ import { IntersectionTypeFormatter } from "../src/TypeFormatter/IntersectionTypeFormatter"; | ||
.addTypeFormatter(new FunctionTypeFormatter()) | ||
.addTypeFormatter(new OptionalTypeFormatter(circularReferenceTypeFormatter)) | ||
@@ -76,0 +79,0 @@ .addTypeFormatter(new RestTypeFormatter(circularReferenceTypeFormatter)) |
{ | ||
"name": "ts-json-schema-generator", | ||
"version": "1.5.1", | ||
"version": "1.5.2--canary.1910.50ff2b2.0", | ||
"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 { UnknownType } from "../Type/UnknownType"; | ||
import { NeverType } from "../Type/NeverType"; | ||
import { FunctionType } from "../Type/FunctionType"; | ||
@@ -29,4 +31,10 @@ export class TypeofNodeParser implements SubNodeParser { | ||
const valueDec = symbol.valueDeclaration!; | ||
if (ts.isEnumDeclaration(valueDec)) { | ||
const valueDec = symbol.valueDeclaration; | ||
if (!valueDec) { | ||
if (symbol.name === "globalThis") { | ||
// avoids crashes on globalThis but we really shoulodn't try to make a schema for globalThis | ||
return new NeverType(); | ||
} | ||
throw new LogicError(`No value declaration found for symbol "${symbol.name}"`); | ||
} else if (ts.isEnumDeclaration(valueDec)) { | ||
return this.createObjectFromEnum(valueDec, context, reference); | ||
@@ -50,5 +58,4 @@ } else if ( | ||
// Silently ignoring Function as JSON Schema does not define them | ||
// see https://github.com/vega/ts-json-schema-generator/issues/98 | ||
return new UnknownType( | ||
`(${(<ts.FunctionDeclaration>valueDec).parameters.map((p) => p.getFullText()).join(",")}) -> ${(< | ||
return new FunctionType( | ||
`(${(<ts.FunctionDeclaration>valueDec).parameters.map((p) => p.getFullText()).join(",")}) ->${(< | ||
ts.FunctionDeclaration | ||
@@ -55,0 +62,0 @@ >valueDec).type?.getFullText()}` |
import { BaseType } from "./BaseType"; | ||
export class FunctionType extends BaseType { | ||
constructor(private comment?: string) { | ||
super(); | ||
} | ||
public getId(): string { | ||
return "function"; | ||
} | ||
public getComment(): string | undefined { | ||
return this.comment; | ||
} | ||
} |
import { BaseType } from "./BaseType"; | ||
export class UnknownType extends BaseType { | ||
constructor(private comment?: string) { | ||
constructor() { | ||
super(); | ||
@@ -10,6 +10,2 @@ } | ||
} | ||
public getComment(): string | undefined { | ||
return this.comment; | ||
} | ||
} |
@@ -11,5 +11,3 @@ import { Definition } from "../Schema/Definition"; | ||
public getDefinition(type: UnknownType): Definition { | ||
return { | ||
$comment: type.getComment(), | ||
}; | ||
return {}; | ||
} | ||
@@ -16,0 +14,0 @@ public getChildren(type: UnknownType): BaseType[] { |
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
913390
730
13591
2