Skip to content

Commit bf28734

Browse files
Merge remote-tracking branch 'quicktype/master' into chore/repo/ts
2 parents 0765671 + 7143aee commit bf28734

91 files changed

Lines changed: 669 additions & 567 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/quicktype-core/src/ConvenienceRenderer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ import {
3232
type TypeKind,
3333
UnionType
3434
} from "./Type";
35-
import { TypeAttributeStoreView } from "./TypeGraph";
36-
import { isNamedType, matchTypeExhaustive, nullableFromUnion, separateNamedTypes } from "./TypeUtils";
35+
import { TypeAttributeStoreView } from "./Type/TypeGraph";
36+
import { isNamedType, matchTypeExhaustive, nullableFromUnion, separateNamedTypes } from "./Type/TypeUtils";
3737

3838
const wordWrap: (s: string) => string = _wordwrap(90);
3939

packages/quicktype-core/src/DeclarationIR.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { iterableFirst, setFilter, setIntersect, setSubtract, setUnionInto } fro
33
import { Graph } from "./Graph";
44
import { messageError } from "./Messages";
55
import { assert, defined, panic } from "./support/Support";
6-
import { type Type } from "./Type";
7-
import { type TypeGraph } from "./TypeGraph";
6+
import { type Type } from "./Type/Type";
7+
import { type TypeGraph } from "./Type/TypeGraph";
88

99
export type DeclarationKind = "forward" | "define";
1010

packages/quicktype-core/src/GatherNames.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import * as pluralize from "pluralize";
44
import { TooManyTypeNames, TypeNames, namesTypeAttributeKind, tooManyNamesThreshold } from "./attributes/TypeNames";
55
import { assert, defined, panic } from "./support/Support";
66
import { transformationForType } from "./Transformers";
7-
import { ObjectType, type Type } from "./Type";
8-
import { type TypeGraph } from "./TypeGraph";
9-
import { matchCompoundType, nullableFromUnion } from "./TypeUtils";
7+
import { ObjectType, type Type } from "./Type/Type";
8+
import { type TypeGraph } from "./Type/TypeGraph";
9+
import { matchCompoundType, nullableFromUnion } from "./Type/TypeUtils";
1010

1111
class UniqueQueue<T> {
1212
private readonly _present = new Set<T>();

packages/quicktype-core/src/GraphRewriting.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ import { EqualityMap, mapMap } from "collection-utils";
33
import { type TypeAttributes, combineTypeAttributes, emptyTypeAttributes } from "./attributes/TypeAttributes";
44
import { assert, indentationString, panic } from "./support/Support";
55
import { type ClassProperty, type MaybeTypeIdentity, type PrimitiveTypeKind, type Type } from "./Type";
6-
// eslint-disable-next-line import/no-cycle
7-
import { type StringTypeMapping, TypeBuilder } from "./TypeBuilder";
6+
import { TypeBuilder } from "./Type/TypeBuilder";
7+
import { type StringTypeMapping } from "./Type/TypeBuilderUtils";
8+
import { type TypeGraph } from "./Type/TypeGraph";
89
import {
9-
type TypeGraph,
1010
type TypeRef,
1111
assertTypeRefGraph,
1212
derefTypeRef,
1313
isTypeRef,
1414
typeAndAttributesForTypeRef,
1515
typeRefIndex
16-
} from "./TypeGraph";
17-
import { combineTypeAttributesOfTypes } from "./TypeUtils";
16+
} from "./Type/TypeRef";
17+
import { combineTypeAttributesOfTypes } from "./Type/TypeUtils";
1818

1919
export interface TypeLookerUp {
2020
lookupTypeRefs: (typeRefs: TypeRef[], forwardingRef?: TypeRef) => TypeRef | undefined;
@@ -229,7 +229,6 @@ export abstract class BaseGraphRewriteBuilder extends TypeBuilder implements Typ
229229
protected readonly debugPrint: boolean
230230
) {
231231
super(
232-
originalGraph.serial + 1,
233232
stringTypeMapping,
234233
alphabetizeProperties,
235234
false,

packages/quicktype-core/src/MakeTransformations.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ import {
3434
isPrimitiveStringTypeKind,
3535
targetTypeKindForTransformedStringTypeKind
3636
} from "./Type";
37-
import { type TypeGraph, type TypeRef, typeRefIndex } from "./TypeGraph";
37+
import { type TypeGraph } from "./Type/TypeGraph";
38+
import { type TypeRef, typeRefIndex } from "./Type/TypeRef";
3839

3940
function transformationAttributes(
4041
graph: TypeGraph,

packages/quicktype-core/src/Renderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { type NewlineSource, type Source, type Sourcelike, annotated, newline, s
66
import { type Comment } from "./support/Comments";
77
import { assert, panic } from "./support/Support";
88
import { type TargetLanguage } from "./TargetLanguage";
9-
import { type TypeGraph } from "./TypeGraph";
9+
import { type TypeGraph } from "./Type/TypeGraph";
1010

1111
export interface RenderResult {
1212
names: ReadonlyMap<Name, string>;

packages/quicktype-core/src/RendererOptions/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import type { EnumOption, Option } from "./index";
22

33
/**
44
* Primary options show up in the web UI in the "Language" settings tab,
5-
* secondary options in "Other".
5+
* Secondary options in "Other".
6+
* CLI is only for cli
67
*/
7-
export type OptionKind = "primary" | "secondary";
8+
export type OptionKind = "primary" | "secondary" | "cli";
89

910
export interface OptionDefinition<Name extends string = string, T = unknown> {
1011
alias?: string;

packages/quicktype-core/src/Run.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ import { type Comment } from "./support/Comments";
1616
import { assert } from "./support/Support";
1717

1818
import { gatherNames } from "./GatherNames";
19-
import { defaultInferenceFlags, inferenceFlagNames, inferenceFlags, InferenceFlags } from "./Inference";
19+
import { type InferenceFlags, defaultInferenceFlags, inferenceFlagNames, inferenceFlags } from "./Inference";
2020
import { makeTransformations } from "./MakeTransformations";
2121
import { messageError } from "./Messages";
2222
import { type Annotation, type Location, type SerializedRenderResult, type Span } from "./Source";
2323
import { type MultiFileRenderResult, type TargetLanguage } from "./TargetLanguage";
24-
import { type StringTypeMapping, TypeBuilder } from "./TypeBuilder";
25-
import { type TypeGraph, noneToAny, optionalToNullable, removeIndirectionIntersections } from "./TypeGraph";
26-
import type { FixMeOptionsType } from "./types";
24+
import { TypeBuilder } from "./Type/TypeBuilder";
25+
import { type StringTypeMapping } from "./Type/TypeBuilderUtils";
26+
import { TypeGraph } from "./Type/TypeGraph";
27+
import { noneToAny, optionalToNullable, removeIndirectionIntersections } from "./Type/TypeGraphUtils";
28+
import { type FixMeOptionsType } from "./types";
2729

2830
export function getTargetLanguage(nameOrInstance: LanguageName | TargetLanguage): TargetLanguage {
2931
if (typeof nameOrInstance === "object") {
@@ -200,13 +202,13 @@ class Run implements RunContext {
200202
const stringTypeMapping = this.stringTypeMapping;
201203
const conflateNumbers = !targetLanguage.supportsUnionsWithBothNumberTypes;
202204
const typeBuilder = new TypeBuilder(
203-
0,
204205
stringTypeMapping,
205206
this._options.alphabetizeProperties,
206207
this._options.allPropertiesOptional,
207208
this._options.checkProvenance,
208209
false
209210
);
211+
typeBuilder.typeGraph = new TypeGraph(typeBuilder, 0, this._options.checkProvenance);
210212

211213
return { targetLanguage, stringTypeMapping, conflateNumbers, typeBuilder };
212214
}

packages/quicktype-core/src/TargetLanguage.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import { type Option, type OptionDefinition } from "./RendererOptions";
77
import { type SerializedRenderResult, serializeRenderResult } from "./Source";
88
import { type Comment } from "./support/Comments";
99
import { defined } from "./support/Support";
10-
import { type Type } from "./Type";
11-
import { type StringTypeMapping } from "./TypeBuilder";
12-
import { type TypeGraph } from "./TypeGraph";
10+
import { type Type } from "./Type/Type";
11+
import { type StringTypeMapping } from "./Type/TypeBuilderUtils";
12+
import { type TypeGraph } from "./Type/TypeGraph";
1313
import { type FixMeOptionsType } from "./types";
1414

1515
export type MultiFileRenderResult = ReadonlyMap<string, SerializedRenderResult>;

packages/quicktype-core/src/Transformers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import { TypeAttributeKind } from "./attributes/TypeAttributes";
1313
import { type BaseGraphRewriteBuilder } from "./GraphRewriting";
1414
import { assert, indentationString, panic } from "./support/Support";
1515
import { EnumType, PrimitiveType, type Type, type TypeKind, UnionType } from "./Type";
16-
import { type TypeGraph, type TypeRef, derefTypeRef } from "./TypeGraph";
16+
import { type TypeGraph } from "./Type/TypeGraph";
17+
import { type TypeRef, derefTypeRef } from "./Type/TypeRef";
1718

1819
function debugStringForType(t: Type): string {
1920
const target = followTargetType(t);

0 commit comments

Comments
 (0)