Skip to content

Commit 6c8f5dc

Browse files
committed
Deprecate it in either direction
1 parent af91582 commit 6c8f5dc

10 files changed

+182
-1
lines changed

src/compiler/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4550,7 +4550,7 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro
45504550
if (options.module === ModuleKind.None || options.module === ModuleKind.AMD || options.module === ModuleKind.UMD || options.module === ModuleKind.System) {
45514551
createDeprecatedDiagnostic("module", ModuleKind[options.module], /*useInstead*/ undefined, /*related*/ undefined);
45524552
}
4553-
if (options.downlevelIteration) {
4553+
if (options.downlevelIteration !== undefined) {
45544554
createDeprecatedDiagnostic("downlevelIteration");
45554555
}
45564556
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error TS5101: Option 'downlevelIteration' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
2+
error TS5107: Option 'target=ES5' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
3+
4+
5+
!!! error TS5101: Option 'downlevelIteration' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
6+
!!! error TS5107: Option 'target=ES5' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
7+
==== downlevelIterationDeprecated.ts (0 errors) ====
8+
declare const log: (s: string) => void;
9+
10+
declare const arr: string[];
11+
12+
for (const a of arr) {
13+
log(a);
14+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//// [tests/cases/compiler/downlevelIterationDeprecated.ts] ////
2+
3+
//// [downlevelIterationDeprecated.ts]
4+
declare const log: (s: string) => void;
5+
6+
declare const arr: string[];
7+
8+
for (const a of arr) {
9+
log(a);
10+
}
11+
12+
//// [downlevelIterationDeprecated.js]
13+
for (var _i = 0, arr_1 = arr; _i < arr_1.length; _i++) {
14+
var a = arr_1[_i];
15+
log(a);
16+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//// [tests/cases/compiler/downlevelIterationDeprecated.ts] ////
2+
3+
=== downlevelIterationDeprecated.ts ===
4+
declare const log: (s: string) => void;
5+
>log : Symbol(log, Decl(downlevelIterationDeprecated.ts, 0, 13))
6+
>s : Symbol(s, Decl(downlevelIterationDeprecated.ts, 0, 20))
7+
8+
declare const arr: string[];
9+
>arr : Symbol(arr, Decl(downlevelIterationDeprecated.ts, 2, 13))
10+
11+
for (const a of arr) {
12+
>a : Symbol(a, Decl(downlevelIterationDeprecated.ts, 4, 10))
13+
>arr : Symbol(arr, Decl(downlevelIterationDeprecated.ts, 2, 13))
14+
15+
log(a);
16+
>log : Symbol(log, Decl(downlevelIterationDeprecated.ts, 0, 13))
17+
>a : Symbol(a, Decl(downlevelIterationDeprecated.ts, 4, 10))
18+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//// [tests/cases/compiler/downlevelIterationDeprecated.ts] ////
2+
3+
=== downlevelIterationDeprecated.ts ===
4+
declare const log: (s: string) => void;
5+
>log : (s: string) => void
6+
> : ^ ^^ ^^^^^
7+
>s : string
8+
> : ^^^^^^
9+
10+
declare const arr: string[];
11+
>arr : string[]
12+
> : ^^^^^^^^
13+
14+
for (const a of arr) {
15+
>a : string
16+
> : ^^^^^^
17+
>arr : string[]
18+
> : ^^^^^^^^
19+
20+
log(a);
21+
>log(a) : void
22+
> : ^^^^
23+
>log : (s: string) => void
24+
> : ^ ^^ ^^^^^
25+
>a : string
26+
> : ^^^^^^
27+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error TS5101: Option 'downlevelIteration' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
2+
error TS5107: Option 'target=ES5' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
3+
4+
5+
!!! error TS5101: Option 'downlevelIteration' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
6+
!!! error TS5107: Option 'target=ES5' is deprecated and will stop functioning in TypeScript 7.0. Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.
7+
==== downlevelIterationDeprecated.ts (0 errors) ====
8+
declare const log: (s: string) => void;
9+
10+
declare const arr: string[];
11+
12+
for (const a of arr) {
13+
log(a);
14+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//// [tests/cases/compiler/downlevelIterationDeprecated.ts] ////
2+
3+
//// [downlevelIterationDeprecated.ts]
4+
declare const log: (s: string) => void;
5+
6+
declare const arr: string[];
7+
8+
for (const a of arr) {
9+
log(a);
10+
}
11+
12+
//// [downlevelIterationDeprecated.js]
13+
var __values = (this && this.__values) || function(o) {
14+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
15+
if (m) return m.call(o);
16+
if (o && typeof o.length === "number") return {
17+
next: function () {
18+
if (o && i >= o.length) o = void 0;
19+
return { value: o && o[i++], done: !o };
20+
}
21+
};
22+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
23+
};
24+
var e_1, _a;
25+
try {
26+
for (var arr_1 = __values(arr), arr_1_1 = arr_1.next(); !arr_1_1.done; arr_1_1 = arr_1.next()) {
27+
var a = arr_1_1.value;
28+
log(a);
29+
}
30+
}
31+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
32+
finally {
33+
try {
34+
if (arr_1_1 && !arr_1_1.done && (_a = arr_1.return)) _a.call(arr_1);
35+
}
36+
finally { if (e_1) throw e_1.error; }
37+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//// [tests/cases/compiler/downlevelIterationDeprecated.ts] ////
2+
3+
=== downlevelIterationDeprecated.ts ===
4+
declare const log: (s: string) => void;
5+
>log : Symbol(log, Decl(downlevelIterationDeprecated.ts, 0, 13))
6+
>s : Symbol(s, Decl(downlevelIterationDeprecated.ts, 0, 20))
7+
8+
declare const arr: string[];
9+
>arr : Symbol(arr, Decl(downlevelIterationDeprecated.ts, 2, 13))
10+
11+
for (const a of arr) {
12+
>a : Symbol(a, Decl(downlevelIterationDeprecated.ts, 4, 10))
13+
>arr : Symbol(arr, Decl(downlevelIterationDeprecated.ts, 2, 13))
14+
15+
log(a);
16+
>log : Symbol(log, Decl(downlevelIterationDeprecated.ts, 0, 13))
17+
>a : Symbol(a, Decl(downlevelIterationDeprecated.ts, 4, 10))
18+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//// [tests/cases/compiler/downlevelIterationDeprecated.ts] ////
2+
3+
=== downlevelIterationDeprecated.ts ===
4+
declare const log: (s: string) => void;
5+
>log : (s: string) => void
6+
> : ^ ^^ ^^^^^
7+
>s : string
8+
> : ^^^^^^
9+
10+
declare const arr: string[];
11+
>arr : string[]
12+
> : ^^^^^^^^
13+
14+
for (const a of arr) {
15+
>a : string
16+
> : ^^^^^^
17+
>arr : string[]
18+
> : ^^^^^^^^
19+
20+
log(a);
21+
>log(a) : void
22+
> : ^^^^
23+
>log : (s: string) => void
24+
> : ^ ^^ ^^^^^
25+
>a : string
26+
> : ^^^^^^
27+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @target: es5
2+
// @downlevelIteration: true,false
3+
4+
declare const log: (s: string) => void;
5+
6+
declare const arr: string[];
7+
8+
for (const a of arr) {
9+
log(a);
10+
}

0 commit comments

Comments
 (0)