File tree Expand file tree Collapse file tree 4 files changed +14
-2
lines changed Expand file tree Collapse file tree 4 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ namespace ts {
69
69
const allowSyntheticDefaultImports = getAllowSyntheticDefaultImports(compilerOptions);
70
70
const strictNullChecks = getStrictOptionValue(compilerOptions, "strictNullChecks");
71
71
const strictFunctionTypes = getStrictOptionValue(compilerOptions, "strictFunctionTypes");
72
+ const strictPropertyInitialization = getStrictOptionValue(compilerOptions, "strictPropertyInitialization");
72
73
const noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny");
73
74
const noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis");
74
75
@@ -22230,7 +22231,7 @@ namespace ts {
22230
22231
}
22231
22232
22232
22233
function checkPropertyInitialization(node: ClassLikeDeclaration) {
22233
- if (!strictNullChecks || node.flags & NodeFlags.Ambient) {
22234
+ if (!strictNullChecks || !strictPropertyInitialization || node.flags & NodeFlags.Ambient) {
22234
22235
return;
22235
22236
}
22236
22237
const constructor = findConstructorDeclaration(node);
Original file line number Diff line number Diff line change @@ -277,6 +277,13 @@ namespace ts {
277
277
category : Diagnostics . Strict_Type_Checking_Options ,
278
278
description : Diagnostics . Enable_strict_checking_of_function_types
279
279
} ,
280
+ {
281
+ name : "strictPropertyInitialization" ,
282
+ type : "boolean" ,
283
+ showInSimplifiedHelpView : true ,
284
+ category : Diagnostics . Strict_Type_Checking_Options ,
285
+ description : Diagnostics . Enable_strict_checking_of_property_initialization_in_classes
286
+ } ,
280
287
{
281
288
name : "noImplicitThis" ,
282
289
type : "boolean" ,
Original file line number Diff line number Diff line change @@ -1923,7 +1923,7 @@ namespace ts {
1923
1923
: moduleKind === ModuleKind . System ;
1924
1924
}
1925
1925
1926
- export type StrictOptionName = "noImplicitAny" | "noImplicitThis" | "strictNullChecks" | "strictFunctionTypes" | "alwaysStrict" ;
1926
+ export type StrictOptionName = "noImplicitAny" | "noImplicitThis" | "strictNullChecks" | "strictFunctionTypes" | "strictPropertyInitialization" | " alwaysStrict";
1927
1927
1928
1928
export function getStrictOptionValue ( compilerOptions : CompilerOptions , flag : StrictOptionName ) : boolean {
1929
1929
return compilerOptions [ flag ] === undefined ? compilerOptions . strict : compilerOptions [ flag ] ;
Original file line number Diff line number Diff line change 3330
3330
"category" : " Message" ,
3331
3331
"code" : 6186
3332
3332
},
3333
+ "Enable strict checking of property initialization in classes." : {
3334
+ "category" : " Message" ,
3335
+ "code" : 6187
3336
+ },
3333
3337
"Variable '{0}' implicitly has an '{1}' type." : {
3334
3338
"category" : " Error" ,
3335
3339
"code" : 7005
You can’t perform that action at this time.
0 commit comments