correctly detect if strictNullChecks is enabled

Fixes: #25808
This commit is contained in:
Klaus Meinhardt
2018-07-20 00:16:59 +02:00
parent 1cedab18be
commit 7031c43978
2 changed files with 46 additions and 1 deletions

View File

@@ -2366,7 +2366,7 @@ namespace ts {
}
function verifyCompilerOptions() {
if (options.strictPropertyInitialization && !options.strictNullChecks) {
if (options.strictPropertyInitialization && !getStrictOptionValue(options, "strictNullChecks")) {
createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
}

View File

@@ -436,6 +436,51 @@ namespace ts {
);
});
it("Correctly detects implicitly enabled strictNullChecks ", () => {
assertCompilerOptions(
{
compilerOptions: {
strict: true,
strictPropertyInitialization: true
}
}, "tsconfig.json",
{
compilerOptions: {
strict: true,
strictPropertyInitialization: true
},
errors: []
}
);
});
it("Checks dependency of strict options ", () => {
assertCompilerOptions(
{
compilerOptions: {
strict: true,
strictNullChecks: false,
strictPropertyInitialization: true
}
}, "tsconfig.json",
{
compilerOptions: {
strict: true,
strictNullChecks: false,
strictPropertyInitialization: true
},
errors: [{
file: undefined,
start: 0,
length: 0,
messageText: "Option 'strictPropertyInitialization' cannot be specified without specifying option 'strictNullChecks'.",
code: Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1.code,
category: Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1.category
}]
}
);
});
// jsconfig.json
it("Convert correctly format jsconfig.json to compiler-options ", () => {
assertCompilerOptions(