Add error reporting for using --noImplicitUseStrict with --options.alwaysStrict

This commit is contained in:
Mohamed Hegazy 2016-10-13 16:54:09 -07:00
parent 418a251237
commit 2920f82804
5 changed files with 78 additions and 0 deletions

View File

@ -1473,6 +1473,10 @@ namespace ts {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib"));
}
if (options.noImplicitUseStrict && options.alwaysStrict) {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict"));
}
const languageVersion = options.target || ScriptTarget.ES3;
const outFile = options.outFile || options.out;

View File

@ -0,0 +1,22 @@
tests/cases/compiler/a.ts(4,13): error TS1100: Invalid use of 'arguments' in strict mode.
tests/cases/compiler/b.ts(3,13): error TS1100: Invalid use of 'arguments' in strict mode.
==== tests/cases/compiler/a.ts (1 errors) ====
module M {
export function f() {
var arguments = [];
~~~~~~~~~
!!! error TS1100: Invalid use of 'arguments' in strict mode.
}
}
==== tests/cases/compiler/b.ts (1 errors) ====
module M {
export function f2() {
var arguments = [];
~~~~~~~~~
!!! error TS1100: Invalid use of 'arguments' in strict mode.
}
}

View File

@ -0,0 +1,34 @@
//// [tests/cases/compiler/alwaysStrictModule2.ts] ////
//// [a.ts]
module M {
export function f() {
var arguments = [];
}
}
//// [b.ts]
module M {
export function f2() {
var arguments = [];
}
}
//// [out.js]
"use strict";
var M;
(function (M) {
function f() {
var arguments = [];
}
M.f = f;
})(M || (M = {}));
"use strict";
var M;
(function (M) {
function f2() {
var arguments = [];
}
M.f2 = f2;
})(M || (M = {}));

View File

@ -1,6 +1,8 @@
error TS5053: Option 'noImplicitUseStrict' cannot be specified with option 'alwaysStrict'.
tests/cases/compiler/alwaysStrictNoImplicitUseStrict.ts(4,13): error TS1100: Invalid use of 'arguments' in strict mode.
!!! error TS5053: Option 'noImplicitUseStrict' cannot be specified with option 'alwaysStrict'.
==== tests/cases/compiler/alwaysStrictNoImplicitUseStrict.ts (1 errors) ====
module M {

View File

@ -0,0 +1,16 @@
// @alwaysStrict: true
// @outFile: out.js
// @fileName: a.ts
module M {
export function f() {
var arguments = [];
}
}
// @fileName: b.ts
module M {
export function f2() {
var arguments = [];
}
}