@@ -22,27 +22,6 @@ import {
22
22
} from './fixtures/nullable.dto' ;
23
23
24
24
describe ( 'API model properties' , ( ) => {
25
- it ( 'should understand nullable' , ( ) => {
26
- const options : ts . CompilerOptions = {
27
- module : ts . ModuleKind . ESNext ,
28
- target : ts . ScriptTarget . ESNext ,
29
- newLine : ts . NewLineKind . LineFeed ,
30
- noEmitHelpers : true ,
31
- strict : true
32
- } ;
33
- const filename = 'nullable.dto.ts' ;
34
- const fakeProgram = ts . createProgram ( [ filename ] , options ) ;
35
-
36
- const result = ts . transpileModule ( nullableDtoText , {
37
- compilerOptions : options ,
38
- fileName : filename ,
39
- transformers : {
40
- before : [ before ( { classValidatorShim : true } , fakeProgram ) ]
41
- }
42
- } ) ;
43
- expect ( result . outputText ) . toEqual ( nullableDtoTextTranspiled ) ;
44
- } ) ;
45
-
46
25
it ( 'should add the metadata factory when no decorators exist' , ( ) => {
47
26
const options : ts . CompilerOptions = {
48
27
module : ts . ModuleKind . ESNext ,
@@ -126,4 +105,25 @@ describe('API model properties', () => {
126
105
} ) ;
127
106
expect ( result . outputText ) . toEqual ( es5CreateCatDtoTextTranspiled ) ;
128
107
} ) ;
108
+
109
+ it ( 'should support & understand nullable type unions' , ( ) => {
110
+ const options : ts . CompilerOptions = {
111
+ module : ts . ModuleKind . ESNext ,
112
+ target : ts . ScriptTarget . ESNext ,
113
+ newLine : ts . NewLineKind . LineFeed ,
114
+ noEmitHelpers : true ,
115
+ strict : true
116
+ } ;
117
+ const filename = 'nullable.dto.ts' ;
118
+ const fakeProgram = ts . createProgram ( [ filename ] , options ) ;
119
+
120
+ const result = ts . transpileModule ( nullableDtoText , {
121
+ compilerOptions : options ,
122
+ fileName : filename ,
123
+ transformers : {
124
+ before : [ before ( { classValidatorShim : true } , fakeProgram ) ]
125
+ }
126
+ } ) ;
127
+ expect ( result . outputText ) . toEqual ( nullableDtoTextTranspiled ) ;
128
+ } ) ;
129
129
} ) ;
0 commit comments