Skip to content

Commit

Permalink
Changed default from ES3 to ES5
Browse files Browse the repository at this point in the history
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.)
  • Loading branch information
perlun committed Apr 29, 2017
1 parent 7080c41 commit 3a70332
Show file tree
Hide file tree
Showing 1,438 changed files with 9,533 additions and 4,804 deletions.
2 changes: 1 addition & 1 deletion src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1477,7 +1477,7 @@ namespace ts {
}

export function getEmitScriptTarget(compilerOptions: CompilerOptions) {
return compilerOptions.target || ScriptTarget.ES3;
return compilerOptions.target || ScriptTarget.ES5;
}

export function getEmitModuleKind(compilerOptions: CompilerOptions) {
Expand Down
8 changes: 4 additions & 4 deletions src/harness/unittests/compileOnSave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,13 +558,13 @@ namespace ts.projectSystem {

const expectedEmittedFileName = "/a/b/f1.js";
assert.isTrue(host.fileExists(expectedEmittedFileName));
assert.equal(host.readFile(expectedEmittedFileName), `"use strict";\r\nexports.__esModule = true;\r\nfunction Foo() { return 10; }\r\nexports.Foo = Foo;\r\n`);
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`);
});

it("shoud not emit js files in external projects", () => {
it("should not emit js files in external projects", () => {
const file1 = {
path: "/a/b/file1.ts",
content: "consonle.log('file1');"
content: "console.log('file1');"
};
// file2 has errors. The emitting should not be blocked.
const file2 = {
Expand Down Expand Up @@ -601,4 +601,4 @@ namespace ts.projectSystem {
assert.isTrue(outFileContent.indexOf(file3.content) === -1);
});
});
}
}
2 changes: 1 addition & 1 deletion tests/baselines/reference/APISample_compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ compile(process.argv.slice(2), {
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler
* Please log a "breaking change" issue for any API breaking change affecting this issue
*/
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", { value: true });
var ts = require("typescript");
function compile(fileNames, options) {
var program = ts.createProgram(fileNames, options);
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/APISample_linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fileNames.forEach(fileName => {
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter
* Please log a "breaking change" issue for any API breaking change affecting this issue
*/
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", { value: true });
var ts = require("typescript");
function delint(sourceFile) {
delintNode(sourceFile);
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/APISample_parseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function createProgram(rootFiles: string[], compilerOptionsJson: string):
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler
* Please log a "breaking change" issue for any API breaking change affecting this issue
*/
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", { value: true });
var ts = require("typescript");
function printError(error) {
if (!error) {
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/APISample_transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ console.log(JSON.stringify(result));
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-simple-transform-function
* Please log a "breaking change" issue for any API breaking change affecting this issue
*/
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", { value: true });
var ts = require("typescript");
var source = "let x: string = 'string'";
var result = ts.transpile(source, { module: ts.ModuleKind.CommonJS });
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/APISample_watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS });
at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#incremental-build-support-using-the-language-services
* Please log a "breaking change" issue for any API breaking change affecting this issue
*/
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", { value: true });
var ts = require("typescript");
function watch(rootFileNames, options) {
var files = {};
Expand Down
7 changes: 0 additions & 7 deletions tests/baselines/reference/ES3For-ofTypeCheck1.errors.txt

This file was deleted.

4 changes: 4 additions & 0 deletions tests/baselines/reference/ES3For-ofTypeCheck1.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck1.ts ===
for (var v of "") { }
>v : Symbol(v, Decl(ES3For-ofTypeCheck1.ts, 0, 8))

5 changes: 5 additions & 0 deletions tests/baselines/reference/ES3For-ofTypeCheck1.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck1.ts ===
for (var v of "") { }
>v : string
>"" : ""

8 changes: 0 additions & 8 deletions tests/baselines/reference/ES3For-ofTypeCheck4.errors.txt

This file was deleted.

8 changes: 8 additions & 0 deletions tests/baselines/reference/ES3For-ofTypeCheck4.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck4.ts ===
var union: string | string[];
>union : Symbol(union, Decl(ES3For-ofTypeCheck4.ts, 0, 3))

for (const v of union) { }
>v : Symbol(v, Decl(ES3For-ofTypeCheck4.ts, 1, 10))
>union : Symbol(union, Decl(ES3For-ofTypeCheck4.ts, 0, 3))

8 changes: 8 additions & 0 deletions tests/baselines/reference/ES3For-ofTypeCheck4.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck4.ts ===
var union: string | string[];
>union : string | string[]

for (const v of union) { }
>v : string
>union : string | string[]

2 changes: 1 addition & 1 deletion tests/baselines/reference/ES5For-of33.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/baselines/reference/ES5For-of33.sourcemap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ sourceFile:ES5For-of33.ts
>>>catch (e_1_1) { e_1 = { error: e_1_1 }; }
>>>finally {
>>> try {
>>> if (_b && !_b.done && (_c = _a["return"])) _c.call(_a);
>>> if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
>>> }
>>> finally { if (e_1) throw e_1.error; }
>>>}
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/ES5For-of34.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/baselines/reference/ES5For-of34.sourcemap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ sourceFile:ES5For-of34.ts
>>>catch (e_1_1) { e_1 = { error: e_1_1 }; }
>>>finally {
>>> try {
>>> if (_b && !_b.done && (_c = _a["return"])) _c.call(_a);
>>> if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
>>> }
>>> finally { if (e_1) throw e_1.error; }
>>>}
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/ES5For-of35.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/baselines/reference/ES5For-of35.sourcemap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ sourceFile:ES5For-of35.ts
>>>catch (e_1_1) { e_1 = { error: e_1_1 }; }
>>>finally {
>>> try {
>>> if (_b && !_b.done && (_f = _a["return"])) _f.call(_a);
>>> if (_b && !_b.done && (_f = _a.return)) _f.call(_a);
>>> }
>>> finally { if (e_1) throw e_1.error; }
>>>}
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/ES5For-of36.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/baselines/reference/ES5For-of36.sourcemap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ sourceFile:ES5For-of36.ts
>>>catch (e_1_1) { e_1 = { error: e_1_1 }; }
>>>finally {
>>> try {
>>> if (_b && !_b.done && (_f = _a["return"])) _f.call(_a);
>>> if (_b && !_b.done && (_f = _a.return)) _f.call(_a);
>>> }
>>> finally { if (e_1) throw e_1.error; }
>>>}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
tests/cases/compiler/MemberAccessorDeclaration15.ts(2,8): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
tests/cases/compiler/MemberAccessorDeclaration15.ts(2,12): error TS2369: A parameter property is only allowed in a constructor implementation.


==== tests/cases/compiler/MemberAccessorDeclaration15.ts (2 errors) ====
==== tests/cases/compiler/MemberAccessorDeclaration15.ts (1 errors) ====
class C {
set Foo(public a: number) { }
~~~
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
~~~~~~~~~~~~~~~~
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export module A {

//// [part1.js]
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", { value: true });
var A;
(function (A) {
var Utils;
Expand All @@ -45,7 +45,7 @@ var A;
})(A = exports.A || (exports.A = {}));
//// [part2.js]
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", { value: true });
var A;
(function (A) {
// collision with 'Origin' var in other part of merged module
Expand Down
35 changes: 0 additions & 35 deletions tests/baselines/reference/accessorWithES3.errors.txt

This file was deleted.

36 changes: 36 additions & 0 deletions tests/baselines/reference/accessorWithES3.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
=== tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithES3.ts ===
// error to use accessors in ES3 mode

class C {
>C : Symbol(C, Decl(accessorWithES3.ts, 0, 0))

get x() {
>x : Symbol(C.x, Decl(accessorWithES3.ts, 2, 9))

return 1;
}
}

class D {
>D : Symbol(D, Decl(accessorWithES3.ts, 6, 1))

set x(v) {
>x : Symbol(D.x, Decl(accessorWithES3.ts, 8, 9))
>v : Symbol(v, Decl(accessorWithES3.ts, 9, 10))
}
}

var x = {
>x : Symbol(x, Decl(accessorWithES3.ts, 13, 3))

get a() { return 1 }
>a : Symbol(a, Decl(accessorWithES3.ts, 13, 9))
}

var y = {
>y : Symbol(y, Decl(accessorWithES3.ts, 17, 3))

set b(v) { }
>b : Symbol(b, Decl(accessorWithES3.ts, 17, 9))
>v : Symbol(v, Decl(accessorWithES3.ts, 18, 10))
}
40 changes: 40 additions & 0 deletions tests/baselines/reference/accessorWithES3.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
=== tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithES3.ts ===
// error to use accessors in ES3 mode

class C {
>C : C

get x() {
>x : number

return 1;
>1 : 1
}
}

class D {
>D : D

set x(v) {
>x : any
>v : any
}
}

var x = {
>x : { readonly a: number; }
>{ get a() { return 1 }} : { readonly a: number; }

get a() { return 1 }
>a : number
>1 : 1
}

var y = {
>y : { b: any; }
>{ set b(v) { }} : { b: any; }

set b(v) { }
>b : any
>v : any
}

This file was deleted.

Loading

0 comments on commit 3a70332

Please sign in to comment.