typia 7.0.0-dev.20240920 → 7.0.0-dev.20240921

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -174,17 +174,16 @@ export namespace JsonStringifyProgrammer {
174
174
  metadata,
175
175
  explore,
176
176
  )(
177
- wrap_functional(
177
+ wrap_functional({
178
178
  input,
179
179
  metadata,
180
180
  explore,
181
- )(
182
- ts.factory.createCallExpression(
181
+ expression: ts.factory.createCallExpression(
183
182
  ts.factory.createIdentifier("JSON.stringify"),
184
183
  undefined,
185
184
  [input],
186
185
  ),
187
- ),
186
+ }),
188
187
  );
189
188
 
190
189
  // ONLY NULL OR UNDEFINED
@@ -470,7 +469,12 @@ export namespace JsonStringifyProgrammer {
470
469
  [],
471
470
  undefined,
472
471
  undefined,
473
- iterate(importer, input, unions, metadata.getName()),
472
+ iterate({
473
+ importer,
474
+ input,
475
+ unions,
476
+ expected: metadata.getName(),
477
+ }),
474
478
  ),
475
479
  undefined,
476
480
  undefined,
@@ -709,7 +713,7 @@ export namespace JsonStringifyProgrammer {
709
713
  empty: ts.factory.createStringLiteral("[]"),
710
714
  success: ts.factory.createTrue(),
711
715
  failure: (input, expected) =>
712
- create_throw_error(importer)(expected)(input),
716
+ create_throw_error({ importer, expected, input }),
713
717
  }),
714
718
  )(input, elements, explore);
715
719
 
@@ -808,40 +812,40 @@ export namespace JsonStringifyProgrammer {
808
812
  );
809
813
  };
810
814
 
811
- const wrap_functional = (
812
- input: ts.Expression,
813
- meta: Metadata,
814
- explore: FeatureProgrammer.IExplore,
815
- ): ((expression: ts.Expression) => ts.Expression) => {
816
- if (meta.functions.length === 0) return (expression) => expression;
817
- return (expression) =>
818
- ts.factory.createConditionalExpression(
819
- ts.factory.createStrictInequality(
820
- ts.factory.createStringLiteral("function"),
821
- ValueFactory.TYPEOF(input),
822
- ),
823
- undefined,
824
- expression,
825
- undefined,
826
- decode_functional(explore),
827
- );
815
+ const wrap_functional = (props: {
816
+ input: ts.Expression;
817
+ metadata: Metadata;
818
+ explore: FeatureProgrammer.IExplore;
819
+ expression: ts.Expression;
820
+ }): ts.Expression => {
821
+ if (props.metadata.functions.length === 0) return props.expression;
822
+ return ts.factory.createConditionalExpression(
823
+ ts.factory.createStrictInequality(
824
+ ts.factory.createStringLiteral("function"),
825
+ ValueFactory.TYPEOF(props.input),
826
+ ),
827
+ undefined,
828
+ props.expression,
829
+ undefined,
830
+ decode_functional(props.explore),
831
+ );
828
832
  };
829
833
 
830
- const iterate = (
831
- importer: FunctionImporter,
832
- input: ts.Expression,
833
- unions: IUnion[],
834
- expected: string,
835
- ) =>
834
+ const iterate = (props: {
835
+ importer: FunctionImporter;
836
+ input: ts.Expression;
837
+ unions: IUnion[];
838
+ expected: string;
839
+ }) =>
836
840
  ts.factory.createBlock(
837
841
  [
838
- ...unions.map((u) =>
842
+ ...props.unions.map((u) =>
839
843
  ts.factory.createIfStatement(
840
844
  u.is(),
841
845
  ts.factory.createReturnStatement(u.value()),
842
846
  ),
843
847
  ),
844
- create_throw_error(importer)(expected)(input),
848
+ create_throw_error(props),
845
849
  ],
846
850
  true,
847
851
  );
@@ -854,7 +858,7 @@ export namespace JsonStringifyProgrammer {
854
858
  const configure =
855
859
  (project: ITypiaContext) =>
856
860
  (importer: FunctionImporter): FeatureProgrammer.IConfig => {
857
- const config: FeatureProgrammer.IConfig = {
861
+ const config: FeatureProgrammer.IConfig<ts.Expression> = {
858
862
  types: {
859
863
  input: (type, name) =>
860
864
  ts.factory.createTypeReferenceNode(
@@ -870,14 +874,18 @@ export namespace JsonStringifyProgrammer {
870
874
  objector: {
871
875
  checker: () => IsProgrammer.decode(project)(importer),
872
876
  decoder: () => decode_object(importer),
873
- joiner: StringifyJoiner.object(importer),
877
+ joiner: (props) =>
878
+ StringifyJoiner.object({
879
+ ...props,
880
+ importer,
881
+ }),
874
882
  unionizer: decode_union_object(
875
883
  IsProgrammer.decode_object(project)(importer),
876
- )(decode_object(importer))((exp) => exp)((value, expected) =>
877
- create_throw_error(importer)(expected)(value),
884
+ )(decode_object(importer))((exp) => exp)((input, expected) =>
885
+ create_throw_error({ importer, expected, input }),
878
886
  ),
879
887
  failure: (input, expected) =>
880
- create_throw_error(importer)(expected)(input),
888
+ create_throw_error({ importer, expected, input }),
881
889
  },
882
890
  generator: {
883
891
  arrays: () => write_array_functions(config)(importer),
@@ -896,28 +904,29 @@ export namespace JsonStringifyProgrammer {
896
904
  type,
897
905
  });
898
906
 
899
- const create_throw_error =
900
- (importer: FunctionImporter) =>
901
- (expected: string) =>
902
- (value: ts.Expression) =>
903
- ts.factory.createExpressionStatement(
904
- ts.factory.createCallExpression(
905
- importer.use("throws"),
906
- [],
907
- [
908
- ts.factory.createObjectLiteralExpression(
909
- [
910
- ts.factory.createPropertyAssignment(
911
- "expected",
912
- ts.factory.createStringLiteral(expected),
913
- ),
914
- ts.factory.createPropertyAssignment("value", value),
915
- ],
916
- true,
917
- ),
918
- ],
919
- ),
920
- );
907
+ const create_throw_error = (props: {
908
+ importer: FunctionImporter;
909
+ expected: string;
910
+ input: ts.Expression;
911
+ }) =>
912
+ ts.factory.createExpressionStatement(
913
+ ts.factory.createCallExpression(
914
+ props.importer.use("throws"),
915
+ [],
916
+ [
917
+ ts.factory.createObjectLiteralExpression(
918
+ [
919
+ ts.factory.createPropertyAssignment(
920
+ "expected",
921
+ ts.factory.createStringLiteral(props.expected),
922
+ ),
923
+ ts.factory.createPropertyAssignment("value", props.input),
924
+ ],
925
+ true,
926
+ ),
927
+ ],
928
+ ),
929
+ );
921
930
  }
922
931
 
923
932
  interface IUnion {