Skip to content

Commit 9971d88

Browse files
committed
Changed default from ES3 to ES5
Fixes microsoft#10117 The fix was easy, but then I had to get the tests passing: ```shell $ gulp runtests # loads of failures, more than 1000 actually. $ gulp baseline-accept $ gulp runtests # to make sure they now passed ``` ...and then `git add .` to add all the changes. (There were a bunch of new files created when I did it like this; is that correct?) ---- (Regarding the unrelated changes in `compileOnSave.ts`: I happened to see a few typing mistakes there very close to the changes I were making to that files, so I bundled that change along at the same time. Since the tests are passing I think it should be fine.)
1 parent 8321b81 commit 9971d88

File tree

1,450 files changed

+9554
-4825
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,450 files changed

+9554
-4825
lines changed

src/compiler/core.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,7 @@ namespace ts {
14861486
}
14871487

14881488
export function getEmitScriptTarget(compilerOptions: CompilerOptions) {
1489-
return compilerOptions.target || ScriptTarget.ES3;
1489+
return compilerOptions.target || ScriptTarget.ES5;
14901490
}
14911491

14921492
export function getEmitModuleKind(compilerOptions: CompilerOptions) {

src/harness/unittests/compileOnSave.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -558,13 +558,13 @@ namespace ts.projectSystem {
558558

559559
const expectedEmittedFileName = "/a/b/f1.js";
560560
assert.isTrue(host.fileExists(expectedEmittedFileName));
561-
assert.equal(host.readFile(expectedEmittedFileName), `"use strict";\r\nexports.__esModule = true;\r\nfunction Foo() { return 10; }\r\nexports.Foo = Foo;\r\n`);
561+
assert.equal(host.readFile(expectedEmittedFileName), `"use strict";\r\nObject.defineProperty(exports, "__esModule", { value: true });\r\nfunction Foo() { return 10; }\r\nexports.Foo = Foo;\r\n`);
562562
});
563563

564-
it("shoud not emit js files in external projects", () => {
564+
it("should not emit js files in external projects", () => {
565565
const file1 = {
566566
path: "/a/b/file1.ts",
567-
content: "consonle.log('file1');"
567+
content: "console.log('file1');"
568568
};
569569
// file2 has errors. The emitting should not be blocked.
570570
const file2 = {
@@ -601,4 +601,4 @@ namespace ts.projectSystem {
601601
assert.isTrue(outFileContent.indexOf(file3.content) === -1);
602602
});
603603
});
604-
}
604+
}

tests/baselines/reference/APISample_compile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ compile(process.argv.slice(2), {
4545
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler
4646
* Please log a "breaking change" issue for any API breaking change affecting this issue
4747
*/
48-
exports.__esModule = true;
48+
Object.defineProperty(exports, "__esModule", { value: true });
4949
var ts = require("typescript");
5050
function compile(fileNames, options) {
5151
var program = ts.createProgram(fileNames, options);

tests/baselines/reference/APISample_linter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fileNames.forEach(fileName => {
7070
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter
7171
* Please log a "breaking change" issue for any API breaking change affecting this issue
7272
*/
73-
exports.__esModule = true;
73+
Object.defineProperty(exports, "__esModule", { value: true });
7474
var ts = require("typescript");
7575
function delint(sourceFile) {
7676
delintNode(sourceFile);

tests/baselines/reference/APISample_parseConfig.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function createProgram(rootFiles: string[], compilerOptionsJson: string):
4242
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler
4343
* Please log a "breaking change" issue for any API breaking change affecting this issue
4444
*/
45-
exports.__esModule = true;
45+
Object.defineProperty(exports, "__esModule", { value: true });
4646
var ts = require("typescript");
4747
function printError(error) {
4848
if (!error) {

tests/baselines/reference/APISample_transform.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ console.log(JSON.stringify(result));
2222
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-simple-transform-function
2323
* Please log a "breaking change" issue for any API breaking change affecting this issue
2424
*/
25-
exports.__esModule = true;
25+
Object.defineProperty(exports, "__esModule", { value: true });
2626
var ts = require("typescript");
2727
var source = "let x: string = 'string'";
2828
var result = ts.transpile(source, { module: ts.ModuleKind.CommonJS });

tests/baselines/reference/APISample_watcher.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS });
116116
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#incremental-build-support-using-the-language-services
117117
* Please log a "breaking change" issue for any API breaking change affecting this issue
118118
*/
119-
exports.__esModule = true;
119+
Object.defineProperty(exports, "__esModule", { value: true });
120120
var ts = require("typescript");
121121
function watch(rootFileNames, options) {
122122
var files = {};

tests/baselines/reference/ES3For-ofTypeCheck1.errors.txt

-7
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck1.ts ===
2+
for (var v of "") { }
3+
>v : Symbol(v, Decl(ES3For-ofTypeCheck1.ts, 0, 8))
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck1.ts ===
2+
for (var v of "") { }
3+
>v : string
4+
>"" : ""
5+

tests/baselines/reference/ES3For-ofTypeCheck4.errors.txt

-8
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck4.ts ===
2+
var union: string | string[];
3+
>union : Symbol(union, Decl(ES3For-ofTypeCheck4.ts, 0, 3))
4+
5+
for (const v of union) { }
6+
>v : Symbol(v, Decl(ES3For-ofTypeCheck4.ts, 1, 10))
7+
>union : Symbol(union, Decl(ES3For-ofTypeCheck4.ts, 0, 3))
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck4.ts ===
2+
var union: string | string[];
3+
>union : string | string[]
4+
5+
for (const v of union) { }
6+
>v : string
7+
>union : string | string[]
8+

tests/baselines/reference/ES5For-of33.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/baselines/reference/ES5For-of33.sourcemap.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ sourceFile:ES5For-of33.ts
120120
>>>catch (e_1_1) { e_1 = { error: e_1_1 }; }
121121
>>>finally {
122122
>>> try {
123-
>>> if (_b && !_b.done && (_c = _a["return"])) _c.call(_a);
123+
>>> if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
124124
>>> }
125125
>>> finally { if (e_1) throw e_1.error; }
126126
>>>}

tests/baselines/reference/ES5For-of34.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/baselines/reference/ES5For-of34.sourcemap.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ sourceFile:ES5For-of34.ts
176176
>>>catch (e_1_1) { e_1 = { error: e_1_1 }; }
177177
>>>finally {
178178
>>> try {
179-
>>> if (_b && !_b.done && (_c = _a["return"])) _c.call(_a);
179+
>>> if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
180180
>>> }
181181
>>> finally { if (e_1) throw e_1.error; }
182182
>>>}

tests/baselines/reference/ES5For-of35.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/baselines/reference/ES5For-of35.sourcemap.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ sourceFile:ES5For-of35.ts
134134
>>>catch (e_1_1) { e_1 = { error: e_1_1 }; }
135135
>>>finally {
136136
>>> try {
137-
>>> if (_b && !_b.done && (_f = _a["return"])) _f.call(_a);
137+
>>> if (_b && !_b.done && (_f = _a.return)) _f.call(_a);
138138
>>> }
139139
>>> finally { if (e_1) throw e_1.error; }
140140
>>>}

tests/baselines/reference/ES5For-of36.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/baselines/reference/ES5For-of36.sourcemap.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ sourceFile:ES5For-of36.ts
150150
>>>catch (e_1_1) { e_1 = { error: e_1_1 }; }
151151
>>>finally {
152152
>>> try {
153-
>>> if (_b && !_b.done && (_f = _a["return"])) _f.call(_a);
153+
>>> if (_b && !_b.done && (_f = _a.return)) _f.call(_a);
154154
>>> }
155155
>>> finally { if (e_1) throw e_1.error; }
156156
>>>}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
tests/cases/compiler/MemberAccessorDeclaration15.ts(2,8): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
21
tests/cases/compiler/MemberAccessorDeclaration15.ts(2,12): error TS2369: A parameter property is only allowed in a constructor implementation.
32

43

5-
==== tests/cases/compiler/MemberAccessorDeclaration15.ts (2 errors) ====
4+
==== tests/cases/compiler/MemberAccessorDeclaration15.ts (1 errors) ====
65
class C {
76
set Foo(public a: number) { }
8-
~~~
9-
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
107
~~~~~~~~~~~~~~~~
118
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
129
}

tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export module A {
3131

3232
//// [part1.js]
3333
"use strict";
34-
exports.__esModule = true;
34+
Object.defineProperty(exports, "__esModule", { value: true });
3535
var A;
3636
(function (A) {
3737
var Utils;
@@ -45,7 +45,7 @@ var A;
4545
})(A = exports.A || (exports.A = {}));
4646
//// [part2.js]
4747
"use strict";
48-
exports.__esModule = true;
48+
Object.defineProperty(exports, "__esModule", { value: true });
4949
var A;
5050
(function (A) {
5151
// collision with 'Origin' var in other part of merged module

tests/baselines/reference/accessorWithES3.errors.txt

-35
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
=== tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithES3.ts ===
2+
// error to use accessors in ES3 mode
3+
4+
class C {
5+
>C : Symbol(C, Decl(accessorWithES3.ts, 0, 0))
6+
7+
get x() {
8+
>x : Symbol(C.x, Decl(accessorWithES3.ts, 2, 9))
9+
10+
return 1;
11+
}
12+
}
13+
14+
class D {
15+
>D : Symbol(D, Decl(accessorWithES3.ts, 6, 1))
16+
17+
set x(v) {
18+
>x : Symbol(D.x, Decl(accessorWithES3.ts, 8, 9))
19+
>v : Symbol(v, Decl(accessorWithES3.ts, 9, 10))
20+
}
21+
}
22+
23+
var x = {
24+
>x : Symbol(x, Decl(accessorWithES3.ts, 13, 3))
25+
26+
get a() { return 1 }
27+
>a : Symbol(a, Decl(accessorWithES3.ts, 13, 9))
28+
}
29+
30+
var y = {
31+
>y : Symbol(y, Decl(accessorWithES3.ts, 17, 3))
32+
33+
set b(v) { }
34+
>b : Symbol(b, Decl(accessorWithES3.ts, 17, 9))
35+
>v : Symbol(v, Decl(accessorWithES3.ts, 18, 10))
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
=== tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithES3.ts ===
2+
// error to use accessors in ES3 mode
3+
4+
class C {
5+
>C : C
6+
7+
get x() {
8+
>x : number
9+
10+
return 1;
11+
>1 : 1
12+
}
13+
}
14+
15+
class D {
16+
>D : D
17+
18+
set x(v) {
19+
>x : any
20+
>v : any
21+
}
22+
}
23+
24+
var x = {
25+
>x : { readonly a: number; }
26+
>{ get a() { return 1 }} : { readonly a: number; }
27+
28+
get a() { return 1 }
29+
>a : number
30+
>1 : 1
31+
}
32+
33+
var y = {
34+
>y : { b: any; }
35+
>{ set b(v) { }} : { b: any; }
36+
37+
set b(v) { }
38+
>b : any
39+
>v : any
40+
}

tests/baselines/reference/accessorsAreNotContextuallyTyped.errors.txt

-22
This file was deleted.

0 commit comments

Comments
 (0)