Skip to content

Commit 2920f82

Browse files
committed
Add error reporting for using --noImplicitUseStrict with --options.alwaysStrict
1 parent 418a251 commit 2920f82

File tree

5 files changed

+78
-0
lines changed

5 files changed

+78
-0
lines changed

src/compiler/program.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,10 @@ namespace ts {
14731473
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib"));
14741474
}
14751475

1476+
if (options.noImplicitUseStrict && options.alwaysStrict) {
1477+
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict"));
1478+
}
1479+
14761480
const languageVersion = options.target || ScriptTarget.ES3;
14771481
const outFile = options.outFile || options.out;
14781482

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
tests/cases/compiler/a.ts(4,13): error TS1100: Invalid use of 'arguments' in strict mode.
2+
tests/cases/compiler/b.ts(3,13): error TS1100: Invalid use of 'arguments' in strict mode.
3+
4+
5+
==== tests/cases/compiler/a.ts (1 errors) ====
6+
7+
module M {
8+
export function f() {
9+
var arguments = [];
10+
~~~~~~~~~
11+
!!! error TS1100: Invalid use of 'arguments' in strict mode.
12+
}
13+
}
14+
15+
==== tests/cases/compiler/b.ts (1 errors) ====
16+
module M {
17+
export function f2() {
18+
var arguments = [];
19+
~~~~~~~~~
20+
!!! error TS1100: Invalid use of 'arguments' in strict mode.
21+
}
22+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//// [tests/cases/compiler/alwaysStrictModule2.ts] ////
2+
3+
//// [a.ts]
4+
5+
module M {
6+
export function f() {
7+
var arguments = [];
8+
}
9+
}
10+
11+
//// [b.ts]
12+
module M {
13+
export function f2() {
14+
var arguments = [];
15+
}
16+
}
17+
18+
//// [out.js]
19+
"use strict";
20+
var M;
21+
(function (M) {
22+
function f() {
23+
var arguments = [];
24+
}
25+
M.f = f;
26+
})(M || (M = {}));
27+
"use strict";
28+
var M;
29+
(function (M) {
30+
function f2() {
31+
var arguments = [];
32+
}
33+
M.f2 = f2;
34+
})(M || (M = {}));

tests/baselines/reference/alwaysStrictNoImplicitUseStrict.errors.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
error TS5053: Option 'noImplicitUseStrict' cannot be specified with option 'alwaysStrict'.
12
tests/cases/compiler/alwaysStrictNoImplicitUseStrict.ts(4,13): error TS1100: Invalid use of 'arguments' in strict mode.
23

34

5+
!!! error TS5053: Option 'noImplicitUseStrict' cannot be specified with option 'alwaysStrict'.
46
==== tests/cases/compiler/alwaysStrictNoImplicitUseStrict.ts (1 errors) ====
57

68
module M {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// @alwaysStrict: true
2+
// @outFile: out.js
3+
4+
// @fileName: a.ts
5+
module M {
6+
export function f() {
7+
var arguments = [];
8+
}
9+
}
10+
11+
// @fileName: b.ts
12+
module M {
13+
export function f2() {
14+
var arguments = [];
15+
}
16+
}

0 commit comments

Comments
 (0)