Repository: DevExpress/devextreme-react
Pull request #110 (2018-05-29 16:24:27)

Clean up a bit


Patch:
diff --git a/tools/src/converter.ts b/tools/src/converter.ts
index 3f0be19..ca74a8d 100644
--- a/tools/src/converter.ts
+++ b/tools/src/converter.ts
@@ -1,7 +1,7 @@
 import { IArrayDescr, ITypeDescr } from "../integration-data-model";
 import { lowercaseFirst } from "./helpers";
 
-function convertTypes(types: string[]): string[] {
+function toPropTypingType(types: string[]): string[] {
     if (types === undefined || types === null || types.length === 0) {
         return;
     }
@@ -73,6 +73,6 @@ const inputTypes = {
 };
 
 export {
-    convertTypes,
+    toPropTypingType,
     findCustomTypeRef
 };
diff --git a/tools/src/generator.ts b/tools/src/generator.ts
index 7eb0c41..9687de7 100644
--- a/tools/src/generator.ts
+++ b/tools/src/generator.ts
@@ -7,7 +7,7 @@ import generateComponent, {
     IOption,
     IPropTyping
 } from "./component-generator";
-import { convertTypes, findCustomTypeRef } from "./converter";
+import { findCustomTypeRef, toPropTypingType } from "./converter";
 import {
   isEmptyArray,
   isNotEmptyArray,
@@ -129,7 +129,7 @@ function createPropTyping(option: IProp): IPropTyping {
   const rawTypes = option.types.filter((t) => !isRestrictedType(t));
   const restrictedTypes = option.types.filter((t) => isRestrictedType(t));
 
-  const types = convertTypes(rawTypes.map((t) => t.isCustomType ? "Object" : t.type));
+  const types = toPropTypingType(rawTypes.map((t) => t.isCustomType ? "Object" : t.type));
 
   if (restrictedTypes.length > 0) {
     return {


Test patch:
diff --git a/tools/src/component-generator.test.ts b/tools/src/component-generator.test.ts
index e9a9e85..145e76f 100644
--- a/tools/src/component-generator.test.ts
+++ b/tools/src/component-generator.test.ts
@@ -378,6 +378,89 @@ export {
         ).toBe(EXPECTED);
     });
 
+    it("processes nested array option", () => {
+        //#region EXPECTED
+        const EXPECTED = `
+import dxCLASS_NAME, {
+    IOptions as ICLASS_NAMEOptions
+} from "devextreme/DX/WIDGET/PATH";
+
+import BaseComponent from "BASE_COMPONENT_PATH";
+import NestedOption from "CONFIG_COMPONENT_PATH";
+
+class CLASS_NAME extends BaseComponent<ICLASS_NAMEOptions> {
+
+  public get instance(): dxCLASS_NAME {
+    return this._instance;
+  }
+
+  protected _WidgetClass = dxCLASS_NAME;
+}
+// tslint:disable:max-classes-per-file
+
+class Opt_1_Component extends NestedOption<{
+  sub_opt_2?: TYPE_1;
+}> {
+  public static IsCollectionItem = true;
+  public static OwnerType = CLASS_NAME;
+  public static OptionName = "opt_1";
+}
+
+class Opt_6_SubComponent extends NestedOption<{
+  sub_sub_sub_opt_8?: TYPE_4;
+}> {
+  public static OwnerType = Opt_1_Component;
+  public static OptionName = "sub_sub_opt_7";
+}
+
+export {
+  CLASS_NAME,
+  ICLASS_NAMEOptions,
+  Opt_1_Component,
+  Opt_6_SubComponent
+};
+`.trimLeft();
+        //#endregion
+
+        expect(
+            generate({
+                name: "CLASS_NAME",
+                baseComponentPath: "BASE_COMPONENT_PATH",
+                configComponentPath: "CONFIG_COMPONENT_PATH",
+                dxExportPath: "DX/WIDGET/PATH",
+                nestedComponents: [
+                    {
+                        className: "Opt_1_Component",
+                        owner: "CLASS_NAME",
+                        optionName: "opt_1",
+                        isCollectionItem: true,
+                        nested: [
+                            {
+                                name: "sub_opt_2",
+                                type: "TYPE_1"
+                            }
+                        ]
+                    },
+
+                    {
+                        className: "Opt_6_SubComponent",
+                        owner: "Opt_1_Component",
+                        optionName: "sub_sub_opt_7",
+                        nested: [
+                            {
+                                name: "sub_sub_sub_opt_8",
+                                type: "TYPE_4"
+                            }
+                        ]
+                    }
+                ]
+            })
+        ).toBe(EXPECTED);
+    });
+});
+
+describe("prop typings", () => {
+
     it("adds check for single type", () => {
         //#region EXPECTED
         const EXPECTED = `
diff --git a/tools/src/converter.test.ts b/tools/src/converter.test.ts
index 6252b1a..b0465bf 100644
--- a/tools/src/converter.test.ts
+++ b/tools/src/converter.test.ts
@@ -1,5 +1,5 @@
 import { IArrayDescr, ITypeDescr } from "../integration-data-model";
-import { convertTypes, findCustomTypeRef } from "./converter";
+import { findCustomTypeRef, toPropTypingType } from "./converter";
 
 it("deduplicates", () => {
     const types = [
@@ -20,24 +20,24 @@ it("deduplicates", () => {
         "string"
     ];
 
-    expect(convertTypes(types)).toEqual(expected);
+    expect(toPropTypingType(types)).toEqual(expected);
 });
 
 it("returns undefiend if finds Any", () => {
-    expect(convertTypes(["Any"])).toBeUndefined();
-    expect(convertTypes(["String", "Any", "Number"])).toBeUndefined();
+    expect(toPropTypingType(["Any"])).toBeUndefined();
+    expect(toPropTypingType(["String", "Any", "Number"])).toBeUndefined();
 });
 
 it("returns undefined if array is empty", () => {
-    expect(convertTypes([])).toBeUndefined();
+    expect(toPropTypingType([])).toBeUndefined();
 });
 
 it("returns undefined if array is undefined", () => {
-    expect(convertTypes([])).toBeUndefined();
+    expect(toPropTypingType([])).toBeUndefined();
 });
 
 it("returns undefined if array is null", () => {
-    expect(convertTypes([])).toBeUndefined();
+    expect(toPropTypingType([])).toBeUndefined();
 });
 
 it("finds custom type", () => {