@@ -46,7 +46,6 @@ func TestTypescriptifyWithTypes(t *testing.T) {
4646 converter := New ()
4747
4848 converter .AddType (reflect .TypeOf (Person {}))
49- converter .CreateFromMethod = false
5049 converter .CreateConstructor = false
5150 converter .BackupDir = ""
5251
@@ -74,7 +73,6 @@ func TestTypescriptifyWithCustomImports(t *testing.T) {
7473 converter := New ()
7574
7675 converter .AddType (reflect .TypeOf (Person {}))
77- converter .CreateFromMethod = false
7876 converter .BackupDir = ""
7977 converter .AddImport ("//import { Decimal } from 'decimal.js'" )
8078 converter .CreateConstructor = false
@@ -107,7 +105,6 @@ func TestTypescriptifyWithInstances(t *testing.T) {
107105
108106 converter .Add (Person {})
109107 converter .Add (Dummy {})
110- converter .CreateFromMethod = false
111108 converter .DontExport = true
112109 converter .BackupDir = ""
113110 converter .CreateConstructor = false
@@ -137,7 +134,6 @@ func TestTypescriptifyWithInterfaces(t *testing.T) {
137134
138135 converter .Add (Person {})
139136 converter .Add (Dummy {})
140- converter .CreateFromMethod = false
141137 converter .DontExport = true
142138 converter .BackupDir = ""
143139 converter .CreateInterface = true
@@ -167,7 +163,6 @@ func TestTypescriptifyWithDoubleClasses(t *testing.T) {
167163
168164 converter .AddType (reflect .TypeOf (Person {}))
169165 converter .AddType (reflect .TypeOf (Person {}))
170- converter .CreateFromMethod = false
171166 converter .CreateConstructor = false
172167 converter .BackupDir = ""
173168
@@ -198,18 +193,12 @@ func TestWithPrefixes(t *testing.T) {
198193 converter .Suffix = "_test"
199194
200195 converter .Add (Person {})
201- converter .CreateFromMethod = false
202196 converter .DontExport = true
203197 converter .BackupDir = ""
204- converter .CreateFromMethod = true
205198
206199 desiredResult := `class test_Dummy_test {
207200 something: string;
208201
209- static createFrom(source: any = {}) {
210- return new test_Dummy_test(source);
211- }
212-
213202 constructor(source: any = {}) {
214203 if ('string' === typeof source) source = JSON.parse(source);
215204 this.something = source["something"];
@@ -219,10 +208,6 @@ class test_Address_test {
219208 duration: number;
220209 text?: string;
221210
222- static createFrom(source: any = {}) {
223- return new test_Address_test(source);
224- }
225-
226211 constructor(source: any = {}) {
227212 if ('string' === typeof source) source = JSON.parse(source);
228213 this.duration = source["duration"];
@@ -238,10 +223,6 @@ class test_Person_test {
238223 friends: test_Person_test[];
239224 a: test_Dummy_test;
240225
241- static createFrom(source: any = {}) {
242- return new test_Person_test(source);
243- }
244-
245226 constructor(source: any = {}) {
246227 if ('string' === typeof source) source = JSON.parse(source);
247228 this.name = source["name"];
@@ -281,6 +262,8 @@ func testConverter(t *testing.T, converter *TypeScriptify, strictMode bool, desi
281262 panic (err .Error ())
282263 }
283264
265+ fmt .Println ("----------------------------------------------------------------------------------------------------" )
266+ fmt .Println (desiredResult )
284267 fmt .Println ("----------------------------------------------------------------------------------------------------" )
285268 fmt .Println (typeScriptCode )
286269 fmt .Println ("----------------------------------------------------------------------------------------------------" )
@@ -356,7 +339,6 @@ func TestTypescriptifyCustomType(t *testing.T) {
356339 converter := New ()
357340
358341 converter .AddType (reflect .TypeOf (TestCustomType {}))
359- converter .CreateFromMethod = false
360342 converter .BackupDir = ""
361343 converter .CreateConstructor = false
362344
@@ -374,16 +356,11 @@ func TestDate(t *testing.T) {
374356
375357 converter := New ()
376358 converter .AddType (reflect .TypeOf (TestCustomType {}))
377- converter .CreateFromMethod = true
378359 converter .BackupDir = ""
379360
380361 desiredResult := `export class TestCustomType {
381362 time: Date;
382363
383- static createFrom(source: any = {}) {
384- return new TestCustomType(source);
385- }
386-
387364 constructor(source: any = {}) {
388365 if ('string' === typeof source) source = JSON.parse(source);
389366 this.time = new Date(source["time"]);
@@ -407,24 +384,18 @@ func TestDateWithoutTags(t *testing.T) {
407384 // Test with custom field options defined per-one-struct:
408385 converter1 := New ()
409386 converter1 .Add (NewStruct (TestCustomType {}).WithFieldOpts (time.Time {}, TypeOptions {TSType : "Date" , TSTransform : "new Date(__VALUE__)" }))
410- converter1 .CreateFromMethod = true
411387 converter1 .BackupDir = ""
412388
413389 // Test with custom field options defined globally:
414390 converter2 := New ()
415391 converter2 .Add (reflect .TypeOf (TestCustomType {}))
416392 converter2 .ManageType (time.Time {}, TypeOptions {TSType : "Date" , TSTransform : "new Date(__VALUE__)" })
417- converter2 .CreateFromMethod = true
418393 converter2 .BackupDir = ""
419394
420395 for _ , converter := range []* TypeScriptify {converter1 , converter2 } {
421396 desiredResult := `export class TestCustomType {
422397 time: Date;
423398
424- static createFrom(source: any = {}) {
425- return new TestCustomType(source);
426- }
427-
428399 constructor(source: any = {}) {
429400 if ('string' === typeof source) source = JSON.parse(source);
430401 this.time = new Date(source["time"]);
@@ -449,16 +420,11 @@ func TestRecursive(t *testing.T) {
449420 converter := New ()
450421
451422 converter .AddType (reflect .TypeOf (Test {}))
452- converter .CreateFromMethod = true
453423 converter .BackupDir = ""
454424
455425 desiredResult := `export class Test {
456426 children: Test[];
457427
458- static createFrom(source: any = {}) {
459- return new Test(source);
460- }
461-
462428 constructor(source: any = {}) {
463429 if ('string' === typeof source) source = JSON.parse(source);
464430 this.children = this.convertValues(source["children"], Test);
@@ -481,16 +447,11 @@ func TestArrayOfArrays(t *testing.T) {
481447 converter := New ()
482448
483449 converter .AddType (reflect .TypeOf (Keyboard {}))
484- converter .CreateFromMethod = true
485450 converter .BackupDir = ""
486451
487452 desiredResult := `export class Key {
488453 key: string;
489454
490- static createFrom(source: any = {}) {
491- return new Key(source);
492- }
493-
494455 constructor(source: any = {}) {
495456 if ('string' === typeof source) source = JSON.parse(source);
496457 this.key = source["key"];
@@ -499,10 +460,6 @@ func TestArrayOfArrays(t *testing.T) {
499460export class Keyboard {
500461 keys: Key[][];
501462
502- static createFrom(source: any = {}) {
503- return new Keyboard(source);
504- }
505-
506463 constructor(source: any = {}) {
507464 if ('string' === typeof source) source = JSON.parse(source);
508465 this.keys = this.convertValues(source["keys"], Key);
@@ -524,7 +481,6 @@ func TestFixedArray(t *testing.T) {
524481 converter := New ()
525482
526483 converter .AddType (reflect .TypeOf (Tmp {}))
527- converter .CreateFromMethod = false
528484 converter .BackupDir = ""
529485
530486 desiredResult := `export class Sub {
@@ -560,16 +516,11 @@ func TestAny(t *testing.T) {
560516 converter := New ()
561517
562518 converter .AddType (reflect .TypeOf (Test {}))
563- converter .CreateFromMethod = true
564519 converter .BackupDir = ""
565520
566521 desiredResult := `export class Test {
567522 field: any;
568523
569- static createFrom(source: any = {}) {
570- return new Test(source);
571- }
572-
573524 constructor(source: any = {}) {
574525 if ('string' === typeof source) source = JSON.parse(source);
575526 this.field = source["field"];
@@ -593,7 +544,6 @@ func TestTypeAlias(t *testing.T) {
593544 converter := New ()
594545
595546 converter .AddType (reflect .TypeOf (Person {}))
596- converter .CreateFromMethod = false
597547 converter .BackupDir = ""
598548 converter .CreateConstructor = false
599549
@@ -622,7 +572,6 @@ func TestOverrideCustomType(t *testing.T) {
622572 converter := New ()
623573
624574 converter .AddType (reflect .TypeOf (SomeStruct {}))
625- converter .CreateFromMethod = false
626575 converter .BackupDir = ""
627576 converter .CreateConstructor = false
628577
@@ -704,8 +653,7 @@ func TestEnum(t *testing.T) {
704653 converter := New ().
705654 AddType (reflect .TypeOf (Holliday {})).
706655 AddEnum (allWeekdays ).
707- WithConstructor (false ).
708- WithCreateFromMethod (true ).
656+ WithConstructor (true ).
709657 WithBackupDir ("" )
710658
711659 desiredResult := `export enum Weekday {
@@ -721,10 +669,6 @@ export class Holliday {
721669 name: string;
722670 weekday: Weekday;
723671
724- static createFrom(source: any = {}) {
725- return new Holliday(source);
726- }
727-
728672 constructor(source: any = {}) {
729673 if ('string' === typeof source) source = JSON.parse(source);
730674 this.name = source["name"];
@@ -755,7 +699,6 @@ func TestEnumWithStringValues(t *testing.T) {
755699 converter := New ().
756700 AddEnum (allGenders ).
757701 WithConstructor (false ).
758- WithCreateFromMethod (false ).
759702 WithBackupDir ("" )
760703
761704 desiredResult := `
@@ -773,7 +716,6 @@ func TestConstructorWithReferences(t *testing.T) {
773716 AddType (reflect .TypeOf (Person {})).
774717 AddEnum (allWeekdaysV2 ).
775718 WithConstructor (true ).
776- WithCreateFromMethod (false ).
777719 WithBackupDir ("" )
778720
779721 desiredResult := `export enum Weekday {
@@ -839,7 +781,6 @@ func TestMaps(t *testing.T) {
839781 converter := New ().
840782 AddType (reflect .TypeOf (WithMap {})).
841783 WithConstructor (true ).
842- WithCreateFromMethod (false ).
843784 WithBackupDir ("" )
844785
845786 desiredResult := `
@@ -895,7 +836,6 @@ func TestPTR(t *testing.T) {
895836 }
896837
897838 converter := New ()
898- converter .CreateFromMethod = false
899839 converter .BackupDir = ""
900840 converter .CreateConstructor = false
901841 converter .Add (Person {})
@@ -918,7 +858,6 @@ func TestAnonymousPtr(t *testing.T) {
918858 converter := New ().
919859 AddType (reflect .TypeOf (PersonWithPtrName {})).
920860 WithConstructor (true ).
921- WithCreateFromMethod (false ).
922861 WithBackupDir ("" )
923862
924863 desiredResult := `
@@ -992,7 +931,6 @@ func TestIgnoredPTR(t *testing.T) {
992931 }
993932
994933 converter := New ()
995- converter .CreateFromMethod = false
996934 converter .BackupDir = ""
997935 converter .Add (PersonWithIgnoredPtr {})
998936
@@ -1022,10 +960,6 @@ func TestMapWithPrefix(t *testing.T) {
1022960export class prefix_Example {
1023961 variable: {[key: string]: string};
1024962
1025- static createFrom(source: any = {}) {
1026- return new prefix_Example(source);
1027- }
1028-
1029963 constructor(source: any = {}) {
1030964 if ('string' === typeof source) source = JSON.parse(source);
1031965 this.variable = source["variable"];
0 commit comments