@@ -28,13 +28,24 @@ runInEachFileSystem(() => {
28
28
29
29
it ( 'should return a check if `strictNullChecks` is enabled' , ( ) => {
30
30
expect ( nullishCoalescingNotNullableFactory . create ( { strictNullChecks : true } ) ) . toBeDefined ( ) ;
31
- expect ( nullishCoalescingNotNullableFactory . create ( { } ) ) . not . toBeNull ( ) ; // Defaults enabled.
32
31
} ) ;
33
32
33
+ it ( 'should return a check if `strictNullChecks` is not configured but `strict` is enabled' ,
34
+ ( ) => {
35
+ expect ( nullishCoalescingNotNullableFactory . create ( { strict : true } ) ) . toBeDefined ( ) ;
36
+ } ) ;
37
+
34
38
it ( 'should not return a check if `strictNullChecks` is disabled' , ( ) => {
35
39
expect ( nullishCoalescingNotNullableFactory . create ( { strictNullChecks : false } ) ) . toBeNull ( ) ;
40
+ expect ( nullishCoalescingNotNullableFactory . create ( { } ) ) . toBeNull ( ) ; // Defaults disabled.
36
41
} ) ;
37
42
43
+ it ( 'should not return a check if `strict` is enabled but `strictNullChecks` is disabled' ,
44
+ ( ) => {
45
+ expect ( nullishCoalescingNotNullableFactory . create ( { strict : true , strictNullChecks : false } ) )
46
+ . toBeNull ( ) ;
47
+ } ) ;
48
+
38
49
it ( 'should produce nullish coalescing warning' , ( ) => {
39
50
const fileName = absoluteFrom ( '/main.ts' ) ;
40
51
const { program, templateTypeChecker} = setup ( [ {
@@ -48,7 +59,7 @@ runInEachFileSystem(() => {
48
59
const component = getClass ( sf , 'TestCmp' ) ;
49
60
const extendedTemplateChecker = new ExtendedTemplateCheckerImpl (
50
61
templateTypeChecker , program . getTypeChecker ( ) , [ nullishCoalescingNotNullableFactory ] ,
51
- { } /* options */ ) ;
62
+ { strictNullChecks : true } /* options */ ) ;
52
63
const diags = extendedTemplateChecker . getDiagnosticsForComponent ( component ) ;
53
64
expect ( diags . length ) . toBe ( 1 ) ;
54
65
expect ( diags [ 0 ] . category ) . toBe ( ts . DiagnosticCategory . Warning ) ;
@@ -69,7 +80,7 @@ runInEachFileSystem(() => {
69
80
const component = getClass ( sf , 'TestCmp' ) ;
70
81
const extendedTemplateChecker = new ExtendedTemplateCheckerImpl (
71
82
templateTypeChecker , program . getTypeChecker ( ) , [ nullishCoalescingNotNullableFactory ] ,
72
- { } /* options */ ) ;
83
+ { strictNullChecks : true } /* options */ ) ;
73
84
const diags = extendedTemplateChecker . getDiagnosticsForComponent ( component ) ;
74
85
expect ( diags . length ) . toBe ( 0 ) ;
75
86
} ) ;
@@ -87,7 +98,7 @@ runInEachFileSystem(() => {
87
98
const component = getClass ( sf , 'TestCmp' ) ;
88
99
const extendedTemplateChecker = new ExtendedTemplateCheckerImpl (
89
100
templateTypeChecker , program . getTypeChecker ( ) , [ nullishCoalescingNotNullableFactory ] ,
90
- { } /* options */ ) ;
101
+ { strictNullChecks : true } /* options */ ) ;
91
102
const diags = extendedTemplateChecker . getDiagnosticsForComponent ( component ) ;
92
103
expect ( diags . length ) . toBe ( 0 ) ;
93
104
} ) ;
@@ -105,7 +116,7 @@ runInEachFileSystem(() => {
105
116
const component = getClass ( sf , 'TestCmp' ) ;
106
117
const extendedTemplateChecker = new ExtendedTemplateCheckerImpl (
107
118
templateTypeChecker , program . getTypeChecker ( ) , [ nullishCoalescingNotNullableFactory ] ,
108
- { } /* options */ ) ;
119
+ { strictNullChecks : true } /* options */ ) ;
109
120
const diags = extendedTemplateChecker . getDiagnosticsForComponent ( component ) ;
110
121
expect ( diags . length ) . toBe ( 0 ) ;
111
122
} ) ;
@@ -123,7 +134,7 @@ runInEachFileSystem(() => {
123
134
const component = getClass ( sf , 'TestCmp' ) ;
124
135
const extendedTemplateChecker = new ExtendedTemplateCheckerImpl (
125
136
templateTypeChecker , program . getTypeChecker ( ) , [ nullishCoalescingNotNullableFactory ] ,
126
- { } /* options */ ) ;
137
+ { strictNullChecks : true } /* options */ ) ;
127
138
const diags = extendedTemplateChecker . getDiagnosticsForComponent ( component ) ;
128
139
expect ( diags . length ) . toBe ( 0 ) ;
129
140
} ) ;
@@ -152,7 +163,7 @@ runInEachFileSystem(() => {
152
163
const component = getClass ( sf , 'TestCmp' ) ;
153
164
const extendedTemplateChecker = new ExtendedTemplateCheckerImpl (
154
165
templateTypeChecker , program . getTypeChecker ( ) , [ nullishCoalescingNotNullableFactory ] ,
155
- { } /* options */ ) ;
166
+ { strictNullChecks : true } /* options */ ) ;
156
167
const diags = extendedTemplateChecker . getDiagnosticsForComponent ( component ) ;
157
168
expect ( diags . length ) . toBe ( 1 ) ;
158
169
expect ( diags [ 0 ] . category ) . toBe ( ts . DiagnosticCategory . Warning ) ;
@@ -185,7 +196,7 @@ runInEachFileSystem(() => {
185
196
const component = getClass ( sf , 'TestCmp' ) ;
186
197
const extendedTemplateChecker = new ExtendedTemplateCheckerImpl (
187
198
templateTypeChecker , program . getTypeChecker ( ) , [ nullishCoalescingNotNullableFactory ] ,
188
- { } /* options */ ) ;
199
+ { strictNullChecks : true } /* options */ ) ;
189
200
const diags = extendedTemplateChecker . getDiagnosticsForComponent ( component ) ;
190
201
expect ( diags . length ) . toBe ( 0 ) ;
191
202
} ) ;
@@ -210,7 +221,7 @@ runInEachFileSystem(() => {
210
221
const component = getClass ( sf , 'TestCmp' ) ;
211
222
const extendedTemplateChecker = new ExtendedTemplateCheckerImpl (
212
223
templateTypeChecker , program . getTypeChecker ( ) , [ nullishCoalescingNotNullableFactory ] ,
213
- { } /* options */ ) ;
224
+ { strictNullChecks : true } /* options */ ) ;
214
225
const diags = extendedTemplateChecker . getDiagnosticsForComponent ( component ) ;
215
226
expect ( diags . length ) . toBe ( 0 ) ;
216
227
} ) ;
@@ -232,6 +243,7 @@ runInEachFileSystem(() => {
232
243
program . getTypeChecker ( ) ,
233
244
[ nullishCoalescingNotNullableFactory ] ,
234
245
{
246
+ strictNullChecks : true ,
235
247
extendedDiagnostics : {
236
248
checks : {
237
249
nullishCoalescingNotNullable : DiagnosticCategoryLabel . Error ,
0 commit comments