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 {
6969 const allowSyntheticDefaultImports = getAllowSyntheticDefaultImports(compilerOptions);
7070 const strictNullChecks = getStrictOptionValue(compilerOptions, "strictNullChecks");
7171 const strictFunctionTypes = getStrictOptionValue(compilerOptions, "strictFunctionTypes");
72+ const strictPropertyInitialization = getStrictOptionValue(compilerOptions, "strictPropertyInitialization");
7273 const noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny");
7374 const noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis");
7475
@@ -22230,7 +22231,7 @@ namespace ts {
2223022231 }
2223122232
2223222233 function checkPropertyInitialization(node: ClassLikeDeclaration) {
22233- if (!strictNullChecks || node.flags & NodeFlags.Ambient) {
22234+ if (!strictNullChecks || !strictPropertyInitialization || node.flags & NodeFlags.Ambient) {
2223422235 return;
2223522236 }
2223622237 const constructor = findConstructorDeclaration(node);
Original file line number Diff line number Diff line change @@ -277,6 +277,13 @@ namespace ts {
277277 category : Diagnostics . Strict_Type_Checking_Options ,
278278 description : Diagnostics . Enable_strict_checking_of_function_types
279279 } ,
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+ } ,
280287 {
281288 name : "noImplicitThis" ,
282289 type : "boolean" ,
Original file line number Diff line number Diff line change @@ -1923,7 +1923,7 @@ namespace ts {
19231923 : moduleKind === ModuleKind . System ;
19241924 }
19251925
1926- export type StrictOptionName = "noImplicitAny" | "noImplicitThis" | "strictNullChecks" | "strictFunctionTypes" | "alwaysStrict" ;
1926+ export type StrictOptionName = "noImplicitAny" | "noImplicitThis" | "strictNullChecks" | "strictFunctionTypes" | "strictPropertyInitialization" | " alwaysStrict";
19271927
19281928 export function getStrictOptionValue ( compilerOptions : CompilerOptions , flag : StrictOptionName ) : boolean {
19291929 return compilerOptions [ flag ] === undefined ? compilerOptions . strict : compilerOptions [ flag ] ;
Original file line number Diff line number Diff line change 33303330 "category" : " Message" ,
33313331 "code" : 6186
33323332 },
3333+ "Enable strict checking of property initialization in classes." : {
3334+ "category" : " Message" ,
3335+ "code" : 6187
3336+ },
33333337 "Variable '{0}' implicitly has an '{1}' type." : {
33343338 "category" : " Error" ,
33353339 "code" : 7005
You can’t perform that action at this time.
0 commit comments