This commit is contained in:
Mark Probst 2018-03-21 20:49:26 -07:00
Родитель 5edccc8b8f
Коммит c089cdafa1
3 изменённых файлов: 8 добавлений и 20 удалений

Просмотреть файл

@ -17,7 +17,7 @@ import {
forEachSync,
checkArray
} from "./Support";
import { TypeGraphBuilder, TypeRef } from "./TypeBuilder";
import { TypeBuilder, TypeRef } from "./TypeBuilder";
import { TypeNames } from "./TypeNames";
import { makeNamesTypeAttributes, modifyTypeNames, singularizeTypeNames } from "./TypeNames";
import {
@ -429,7 +429,7 @@ function checkTypeList(typeOrTypes: any): OrderedSet<string> {
}
export async function addTypesInSchema(
typeBuilder: TypeGraphBuilder,
typeBuilder: TypeBuilder,
store: JSONSchemaStore,
references: Map<string, Ref>
): Promise<void> {

Просмотреть файл

@ -147,7 +147,7 @@ export const NoStringTypeMapping: StringTypeMapping = {
dateTime: "date-time"
};
export abstract class TypeBuilder {
export class TypeBuilder {
readonly typeGraph: TypeGraph;
protected topLevels: Map<string, TypeRef> = Map();
@ -412,7 +412,9 @@ export abstract class TypeBuilder {
type.setMembers(members);
}
abstract setLostTypeAttributes(): void;
setLostTypeAttributes(): void {
return;
}
}
export interface TypeLookerUp {
@ -421,20 +423,6 @@ export interface TypeLookerUp {
registerUnion(typeRefs: TypeRef[], reconstituted: TypeRef): void;
}
export class TypeGraphBuilder extends TypeBuilder {
protected typeForEntry(entry: Type | undefined): Type | undefined {
return entry;
}
getLazyMapType(valuesCreator: () => TypeRef | undefined): TypeRef {
return this.addType(undefined, tref => new MapType(tref, valuesCreator()), undefined);
}
setLostTypeAttributes(): void {
return;
}
}
export class TypeReconstituter {
private _wasUsed: boolean = false;

Просмотреть файл

@ -14,7 +14,7 @@ import { addTypesInSchema, Ref, definitionRefsInSchema, checkJSONSchema } from "
import { JSONSchema, JSONSchemaStore } from "./JSONSchemaStore";
import { TypeInference } from "./Inference";
import { inferMaps } from "./InferMaps";
import { TypeGraphBuilder } from "./TypeBuilder";
import { TypeBuilder } from "./TypeBuilder";
import { TypeGraph, noneToAny, optionalToNullable } from "./TypeGraph";
import { makeNamesTypeAttributes } from "./TypeNames";
import { makeGraphQLQueryTypes } from "./GraphQL";
@ -179,7 +179,7 @@ export class Run {
const stringTypeMapping = targetLanguage.stringTypeMapping;
const conflateNumbers = !targetLanguage.supportsUnionsWithBothNumberTypes;
const haveSchemas = Object.getOwnPropertyNames(this._allInputs.schemas).length > 0;
const typeBuilder = new TypeGraphBuilder(
const typeBuilder = new TypeBuilder(
stringTypeMapping,
this._options.alphabetizeProperties,
this._options.allPropertiesOptional,