mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-02 14:48:32 -05:00
Merge pull request #4111 from Microsoft/systemModuleWithEmitHelpers
Fix the emit helper emit inside the system modules
This commit is contained in:
@@ -6259,6 +6259,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
write(`], function(${exportFunctionForFile}) {`);
|
||||
writeLine();
|
||||
increaseIndent();
|
||||
emitEmitHelpers(node);
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
emitSystemModuleBody(node, startIndex);
|
||||
decreaseIndent();
|
||||
@@ -6330,6 +6331,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function emitAMDModule(node: SourceFile, startIndex: number) {
|
||||
emitEmitHelpers(node);
|
||||
collectExternalModuleInfo(node);
|
||||
|
||||
writeLine();
|
||||
@@ -6351,6 +6353,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function emitCommonJSModule(node: SourceFile, startIndex: number) {
|
||||
emitEmitHelpers(node);
|
||||
collectExternalModuleInfo(node);
|
||||
emitExportStarHelper();
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
@@ -6360,6 +6363,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function emitUMDModule(node: SourceFile, startIndex: number) {
|
||||
emitEmitHelpers(node);
|
||||
collectExternalModuleInfo(node);
|
||||
|
||||
// Module is detected first to support Browserify users that load into a browser with an AMD loader
|
||||
@@ -6389,6 +6393,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
exportSpecifiers = undefined;
|
||||
exportEquals = undefined;
|
||||
hasExportStars = false;
|
||||
emitEmitHelpers(node);
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
emitLinesStartingAt(node.statements, startIndex);
|
||||
emitTempDeclarations(/*newLine*/ true);
|
||||
@@ -6527,14 +6532,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
}
|
||||
|
||||
function emitSourceFileNode(node: SourceFile) {
|
||||
// Start new file on new line
|
||||
writeLine();
|
||||
emitDetachedComments(node);
|
||||
|
||||
// emit prologue directives prior to __extends
|
||||
let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false);
|
||||
|
||||
function emitEmitHelpers(node: SourceFile): void {
|
||||
// Only emit helpers if the user did not say otherwise.
|
||||
if (!compilerOptions.noEmitHelpers) {
|
||||
// Only Emit __extends function when target ES5.
|
||||
@@ -6562,6 +6560,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
awaiterEmitted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function emitSourceFileNode(node: SourceFile) {
|
||||
// Start new file on new line
|
||||
writeLine();
|
||||
emitDetachedComments(node);
|
||||
|
||||
// emit prologue directives prior to __extends
|
||||
let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false);
|
||||
|
||||
if (isExternalModule(node) || compilerOptions.isolatedModules) {
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
@@ -6585,6 +6592,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
exportSpecifiers = undefined;
|
||||
exportEquals = undefined;
|
||||
hasExportStars = false;
|
||||
emitEmitHelpers(node);
|
||||
emitCaptureThisForNodeIfNecessary(node);
|
||||
emitLinesStartingAt(node.statements, startIndex);
|
||||
emitTempDeclarations(/*newLine*/ true);
|
||||
|
||||
55
tests/baselines/reference/systemModuleWithSuperClass.js
Normal file
55
tests/baselines/reference/systemModuleWithSuperClass.js
Normal file
@@ -0,0 +1,55 @@
|
||||
//// [tests/cases/compiler/systemModuleWithSuperClass.ts] ////
|
||||
|
||||
//// [foo.ts]
|
||||
|
||||
export class Foo {
|
||||
a: string;
|
||||
}
|
||||
|
||||
//// [bar.ts]
|
||||
import {Foo} from './foo';
|
||||
export class Bar extends Foo {
|
||||
b: string;
|
||||
}
|
||||
|
||||
//// [foo.js]
|
||||
System.register([], function(exports_1) {
|
||||
var Foo;
|
||||
return {
|
||||
setters:[],
|
||||
execute: function() {
|
||||
Foo = (function () {
|
||||
function Foo() {
|
||||
}
|
||||
return Foo;
|
||||
})();
|
||||
exports_1("Foo", Foo);
|
||||
}
|
||||
}
|
||||
});
|
||||
//// [bar.js]
|
||||
System.register(['./foo'], function(exports_1) {
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var foo_1;
|
||||
var Bar;
|
||||
return {
|
||||
setters:[
|
||||
function (_foo_1) {
|
||||
foo_1 = _foo_1;
|
||||
}],
|
||||
execute: function() {
|
||||
Bar = (function (_super) {
|
||||
__extends(Bar, _super);
|
||||
function Bar() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return Bar;
|
||||
})(foo_1.Foo);
|
||||
exports_1("Bar", Bar);
|
||||
}
|
||||
}
|
||||
});
|
||||
20
tests/baselines/reference/systemModuleWithSuperClass.symbols
Normal file
20
tests/baselines/reference/systemModuleWithSuperClass.symbols
Normal file
@@ -0,0 +1,20 @@
|
||||
=== tests/cases/compiler/foo.ts ===
|
||||
|
||||
export class Foo {
|
||||
>Foo : Symbol(Foo, Decl(foo.ts, 0, 0))
|
||||
|
||||
a: string;
|
||||
>a : Symbol(a, Decl(foo.ts, 1, 18))
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/bar.ts ===
|
||||
import {Foo} from './foo';
|
||||
>Foo : Symbol(Foo, Decl(bar.ts, 0, 8))
|
||||
|
||||
export class Bar extends Foo {
|
||||
>Bar : Symbol(Bar, Decl(bar.ts, 0, 26))
|
||||
>Foo : Symbol(Foo, Decl(bar.ts, 0, 8))
|
||||
|
||||
b: string;
|
||||
>b : Symbol(b, Decl(bar.ts, 1, 30))
|
||||
}
|
||||
20
tests/baselines/reference/systemModuleWithSuperClass.types
Normal file
20
tests/baselines/reference/systemModuleWithSuperClass.types
Normal file
@@ -0,0 +1,20 @@
|
||||
=== tests/cases/compiler/foo.ts ===
|
||||
|
||||
export class Foo {
|
||||
>Foo : Foo
|
||||
|
||||
a: string;
|
||||
>a : string
|
||||
}
|
||||
|
||||
=== tests/cases/compiler/bar.ts ===
|
||||
import {Foo} from './foo';
|
||||
>Foo : typeof Foo
|
||||
|
||||
export class Bar extends Foo {
|
||||
>Bar : Bar
|
||||
>Foo : Foo
|
||||
|
||||
b: string;
|
||||
>b : string
|
||||
}
|
||||
12
tests/cases/compiler/systemModuleWithSuperClass.ts
Normal file
12
tests/cases/compiler/systemModuleWithSuperClass.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
// @module: system
|
||||
|
||||
// @Filename: foo.ts
|
||||
export class Foo {
|
||||
a: string;
|
||||
}
|
||||
|
||||
// @Filename: bar.ts
|
||||
import {Foo} from './foo';
|
||||
export class Bar extends Foo {
|
||||
b: string;
|
||||
}
|
||||
Reference in New Issue
Block a user