UNPKG

ts-json-schema-generator

Version:

Generate JSON schema from your Typescript sources

31 lines (24 loc) 799 B
import type ts from "typescript"; import { BaseType } from "./BaseType.js"; import type { ObjectType } from "./ObjectType.js"; export class FunctionType extends BaseType { private comment: string; constructor( node?: ts.FunctionTypeNode | ts.FunctionExpression | ts.FunctionDeclaration | ts.ArrowFunction, protected namedArguments?: ObjectType, ) { super(); if (node) { this.comment = `(${node.parameters.map((p) => p.getFullText()).join(",")}) =>${node.type?.getFullText()}`; } } public getId(): string { return "function"; } public getComment(): string | undefined { return this.comment; } public getNamedArguments(): ObjectType | undefined { return this.namedArguments; } }