Skip to content

Commit 2ef7483

Browse files
committed
Merge branch 'transforms' into transforms-fixMoreSourceMaps
2 parents 7853882 + 695d92f commit 2ef7483

24 files changed

Lines changed: 476 additions & 27 deletions

src/compiler/transformers/module/module.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -423,10 +423,10 @@ namespace ts {
423423
createVariableDeclarationList([
424424
createVariableDeclaration(
425425
generatedName,
426-
createRequireCall(node),
427-
/*location*/ node
426+
createRequireCall(node)
428427
)
429-
])
428+
]),
429+
/*location*/ node
430430
)
431431
);
432432
}
@@ -523,10 +523,15 @@ namespace ts {
523523
}
524524
}
525525

526-
function addExportImportAssignments(statements: Statement[], node: Node) {
527-
const names = reduceEachChild(node, collectExportMembers, []);
528-
for (const name of names) {
529-
addExportMemberAssignments(statements, name);
526+
function addExportImportAssignments(statements: Statement[], node: ImportEqualsDeclaration | ImportDeclaration) {
527+
if (isImportEqualsDeclaration(node)) {
528+
addExportMemberAssignments(statements, node.name);
529+
}
530+
else {
531+
const names = reduceEachChild(node, collectExportMembers, []);
532+
for (const name of names) {
533+
addExportMemberAssignments(statements, name);
534+
}
530535
}
531536
}
532537

@@ -739,9 +744,6 @@ namespace ts {
739744

740745
addExportMemberAssignments(statements, classDecl.name);
741746

742-
if (statements.length > 1) {
743-
Debug.assert(!!classDecl.decorators, "Expression statements should only have an export member assignment when decorated.")
744-
}
745747
return statements;
746748
}
747749
}

src/compiler/transformers/ts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2750,7 +2750,7 @@ namespace ts {
27502750
*/
27512751
function isNamedExternalModuleExport(node: Node) {
27522752
return isExternalModuleExport(node)
2753-
&& hasModifier(node, ModifierFlags.Default);
2753+
&& !hasModifier(node, ModifierFlags.Default);
27542754
}
27552755

27562756
/**

src/harness/rwcRunner.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,9 @@ namespace RWC {
190190
if (compilerResult.errors.length === 0) {
191191
return null;
192192
}
193-
194-
return Harness.Compiler.getErrorBaseline(inputFiles.concat(otherFiles), compilerResult.errors);
193+
// Do not include the library in the baselines to avoid noise
194+
const baselineFiles = inputFiles.concat(otherFiles).filter(f => !Harness.isDefaultLibraryFile(f.unitName));
195+
return Harness.Compiler.getErrorBaseline(baselineFiles, compilerResult.errors);
195196
}, false, baselineOpts);
196197
});
197198

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//// [tests/cases/compiler/commentsOnRequireStatement.ts] ////
2+
3+
//// [0.ts]
4+
5+
export var subject = 10;
6+
7+
//// [1.ts]
8+
export var subject1 = 10;
9+
10+
//// [2.ts]
11+
/* blah0 */
12+
// blah
13+
// blah
14+
// blah
15+
export {subject} from './0';
16+
/* blah1 */
17+
export {subject1} from './1';
18+
19+
20+
//// [0.js]
21+
"use strict";
22+
exports.subject = 10;
23+
//// [1.js]
24+
"use strict";
25+
exports.subject1 = 10;
26+
//// [2.js]
27+
"use strict";
28+
/* blah0 */
29+
// blah
30+
// blah
31+
// blah
32+
var _0_1 = require("./0");
33+
exports.subject = _0_1.subject;
34+
/* blah1 */
35+
var _1_1 = require("./1");
36+
exports.subject1 = _1_1.subject1;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
=== tests/cases/compiler/0.ts ===
2+
3+
export var subject = 10;
4+
>subject : Symbol(subject, Decl(0.ts, 1, 10))
5+
6+
=== tests/cases/compiler/1.ts ===
7+
export var subject1 = 10;
8+
>subject1 : Symbol(subject1, Decl(1.ts, 0, 10))
9+
10+
=== tests/cases/compiler/2.ts ===
11+
/* blah0 */
12+
// blah
13+
// blah
14+
// blah
15+
export {subject} from './0';
16+
>subject : Symbol(subject, Decl(2.ts, 4, 8))
17+
18+
/* blah1 */
19+
export {subject1} from './1';
20+
>subject1 : Symbol(subject1, Decl(2.ts, 6, 8))
21+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
=== tests/cases/compiler/0.ts ===
2+
3+
export var subject = 10;
4+
>subject : number
5+
>10 : number
6+
7+
=== tests/cases/compiler/1.ts ===
8+
export var subject1 = 10;
9+
>subject1 : number
10+
>10 : number
11+
12+
=== tests/cases/compiler/2.ts ===
13+
/* blah0 */
14+
// blah
15+
// blah
16+
// blah
17+
export {subject} from './0';
18+
>subject : number
19+
20+
/* blah1 */
21+
export {subject1} from './1';
22+
>subject1 : number
23+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//// [tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor2.ts] ////
2+
3+
//// [0.ts]
4+
5+
export class base { }
6+
export function foo(target: Object, propertyKey: string | symbol, parameterIndex: number) { }
7+
8+
//// [2.ts]
9+
import {base} from "./0.ts"
10+
import {foo} from "./0.ts"
11+
export class C extends base{
12+
constructor(@foo prop: any) {
13+
super();
14+
}
15+
}
16+
17+
//// [0.js]
18+
"use strict";
19+
var base = (function () {
20+
function base() {
21+
}
22+
return base;
23+
}());
24+
exports.base = base;
25+
function foo(target, propertyKey, parameterIndex) { }
26+
exports.foo = foo;
27+
//// [2.js]
28+
"use strict";
29+
var __extends = (this && this.__extends) || function (d, b) {
30+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
31+
function __() { this.constructor = d; }
32+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
33+
};
34+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
35+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
36+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
37+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
38+
return c > 3 && r && Object.defineProperty(target, key, r), r;
39+
};
40+
var __param = (this && this.__param) || function (paramIndex, decorator) {
41+
return function (target, key) { decorator(target, key, paramIndex); }
42+
};
43+
var _0_ts_1 = require("./0.ts");
44+
var _0_ts_2 = require("./0.ts");
45+
var C = (function (_super) {
46+
__extends(C, _super);
47+
function C(prop) {
48+
_super.call(this);
49+
}
50+
return C;
51+
}(_0_ts_1.base));
52+
exports.C = C;
53+
C = __decorate([
54+
__param(0, _0_ts_2.foo)
55+
], C);
56+
exports.C = C;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
=== tests/cases/conformance/decorators/class/constructor/0.ts ===
2+
3+
export class base { }
4+
>base : Symbol(base, Decl(0.ts, 0, 0))
5+
6+
export function foo(target: Object, propertyKey: string | symbol, parameterIndex: number) { }
7+
>foo : Symbol(foo, Decl(0.ts, 1, 21))
8+
>target : Symbol(target, Decl(0.ts, 2, 20))
9+
>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
10+
>propertyKey : Symbol(propertyKey, Decl(0.ts, 2, 35))
11+
>parameterIndex : Symbol(parameterIndex, Decl(0.ts, 2, 65))
12+
13+
=== tests/cases/conformance/decorators/class/constructor/2.ts ===
14+
import {base} from "./0.ts"
15+
>base : Symbol(base, Decl(2.ts, 0, 8))
16+
17+
import {foo} from "./0.ts"
18+
>foo : Symbol(foo, Decl(2.ts, 1, 8))
19+
20+
export class C extends base{
21+
>C : Symbol(C, Decl(2.ts, 1, 26))
22+
>base : Symbol(base, Decl(2.ts, 0, 8))
23+
24+
constructor(@foo prop: any) {
25+
>foo : Symbol(foo, Decl(2.ts, 1, 8))
26+
>prop : Symbol(prop, Decl(2.ts, 3, 16))
27+
28+
super();
29+
>super : Symbol(base, Decl(0.ts, 0, 0))
30+
}
31+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
=== tests/cases/conformance/decorators/class/constructor/0.ts ===
2+
3+
export class base { }
4+
>base : base
5+
6+
export function foo(target: Object, propertyKey: string | symbol, parameterIndex: number) { }
7+
>foo : (target: Object, propertyKey: string | symbol, parameterIndex: number) => void
8+
>target : Object
9+
>Object : Object
10+
>propertyKey : string | symbol
11+
>parameterIndex : number
12+
13+
=== tests/cases/conformance/decorators/class/constructor/2.ts ===
14+
import {base} from "./0.ts"
15+
>base : typeof base
16+
17+
import {foo} from "./0.ts"
18+
>foo : (target: Object, propertyKey: string | symbol, parameterIndex: number) => void
19+
20+
export class C extends base{
21+
>C : C
22+
>base : base
23+
24+
constructor(@foo prop: any) {
25+
>foo : (target: Object, propertyKey: string | symbol, parameterIndex: number) => void
26+
>prop : any
27+
28+
super();
29+
>super() : void
30+
>super : typeof base
31+
}
32+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//// [tests/cases/conformance/es6/modules/defaultExportInAwaitExpression01.ts] ////
2+
3+
//// [a.ts]
4+
const x = new Promise( ( resolve, reject ) => { resolve( {} ); } );
5+
export default x;
6+
7+
//// [b.ts]
8+
import x from './a';
9+
10+
( async function() {
11+
const value = await x;
12+
}() );
13+
14+
15+
//// [a.js]
16+
(function (dependencies, factory) {
17+
if (typeof module === 'object' && typeof module.exports === 'object') {
18+
var v = factory(require, exports); if (v !== undefined) module.exports = v;
19+
}
20+
else if (typeof define === 'function' && define.amd) {
21+
define(dependencies, factory);
22+
}
23+
})(["require", "exports"], function (require, exports) {
24+
"use strict";
25+
const x = new Promise((resolve, reject) => { resolve({}); });
26+
Object.defineProperty(exports, "__esModule", { value: true });
27+
exports.default = x;
28+
});
29+
//// [b.js]
30+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
31+
return new (P || (P = Promise))(function (resolve, reject) {
32+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
33+
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
34+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
35+
step((generator = generator.apply(thisArg, _arguments)).next());
36+
});
37+
};
38+
(function (dependencies, factory) {
39+
if (typeof module === 'object' && typeof module.exports === 'object') {
40+
var v = factory(require, exports); if (v !== undefined) module.exports = v;
41+
}
42+
else if (typeof define === 'function' && define.amd) {
43+
define(dependencies, factory);
44+
}
45+
})(["require", "exports", "./a"], function (require, exports) {
46+
"use strict";
47+
const a_1 = require("./a");
48+
(function () {
49+
return __awaiter(this, void 0, void 0, function* () {
50+
const value = yield a_1.default;
51+
});
52+
}());
53+
});

0 commit comments

Comments
 (0)