-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7559 from Microsoft/rewrite-class-as-expr
emit top level classes as class expressions when target=ES6 and module=System
- Loading branch information
Showing
9 changed files
with
142 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//// [systemModuleTargetES6.ts] | ||
export class MyClass { } | ||
export class MyClass2 { | ||
static value = 42; | ||
static getInstance() { return MyClass2.value; } | ||
} | ||
|
||
export function myFunction() { | ||
return new MyClass(); | ||
} | ||
|
||
export function myFunction2() { | ||
return new MyClass2(); | ||
} | ||
|
||
//// [systemModuleTargetES6.js] | ||
System.register([], function(exports_1, context_1) { | ||
"use strict"; | ||
var __moduleName = context_1 && context_1.id; | ||
var MyClass, MyClass2; | ||
function myFunction() { | ||
return new MyClass(); | ||
} | ||
exports_1("myFunction", myFunction); | ||
function myFunction2() { | ||
return new MyClass2(); | ||
} | ||
exports_1("myFunction2", myFunction2); | ||
return { | ||
setters:[], | ||
execute: function() { | ||
MyClass = class MyClass { | ||
}; | ||
exports_1("MyClass", MyClass); | ||
MyClass2 = class MyClass2 { | ||
static getInstance() { return MyClass2.value; } | ||
}; | ||
MyClass2.value = 42; | ||
exports_1("MyClass2", MyClass2); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
=== tests/cases/compiler/systemModuleTargetES6.ts === | ||
export class MyClass { } | ||
>MyClass : Symbol(MyClass, Decl(systemModuleTargetES6.ts, 0, 0)) | ||
|
||
export class MyClass2 { | ||
>MyClass2 : Symbol(MyClass2, Decl(systemModuleTargetES6.ts, 0, 24)) | ||
|
||
static value = 42; | ||
>value : Symbol(MyClass2.value, Decl(systemModuleTargetES6.ts, 1, 23)) | ||
|
||
static getInstance() { return MyClass2.value; } | ||
>getInstance : Symbol(MyClass2.getInstance, Decl(systemModuleTargetES6.ts, 2, 22)) | ||
>MyClass2.value : Symbol(MyClass2.value, Decl(systemModuleTargetES6.ts, 1, 23)) | ||
>MyClass2 : Symbol(MyClass2, Decl(systemModuleTargetES6.ts, 0, 24)) | ||
>value : Symbol(MyClass2.value, Decl(systemModuleTargetES6.ts, 1, 23)) | ||
} | ||
|
||
export function myFunction() { | ||
>myFunction : Symbol(myFunction, Decl(systemModuleTargetES6.ts, 4, 1)) | ||
|
||
return new MyClass(); | ||
>MyClass : Symbol(MyClass, Decl(systemModuleTargetES6.ts, 0, 0)) | ||
} | ||
|
||
export function myFunction2() { | ||
>myFunction2 : Symbol(myFunction2, Decl(systemModuleTargetES6.ts, 8, 1)) | ||
|
||
return new MyClass2(); | ||
>MyClass2 : Symbol(MyClass2, Decl(systemModuleTargetES6.ts, 0, 24)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
=== tests/cases/compiler/systemModuleTargetES6.ts === | ||
export class MyClass { } | ||
>MyClass : MyClass | ||
|
||
export class MyClass2 { | ||
>MyClass2 : MyClass2 | ||
|
||
static value = 42; | ||
>value : number | ||
>42 : number | ||
|
||
static getInstance() { return MyClass2.value; } | ||
>getInstance : () => number | ||
>MyClass2.value : number | ||
>MyClass2 : typeof MyClass2 | ||
>value : number | ||
} | ||
|
||
export function myFunction() { | ||
>myFunction : () => MyClass | ||
|
||
return new MyClass(); | ||
>new MyClass() : MyClass | ||
>MyClass : typeof MyClass | ||
} | ||
|
||
export function myFunction2() { | ||
>myFunction2 : () => MyClass2 | ||
|
||
return new MyClass2(); | ||
>new MyClass2() : MyClass2 | ||
>MyClass2 : typeof MyClass2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// @target: ES6 | ||
// @module: System | ||
export class MyClass { } | ||
export class MyClass2 { | ||
static value = 42; | ||
static getInstance() { return MyClass2.value; } | ||
} | ||
|
||
export function myFunction() { | ||
return new MyClass(); | ||
} | ||
|
||
export function myFunction2() { | ||
return new MyClass2(); | ||
} |