mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-11 10:00:13 -06:00
Some tests to cover transpilation of different syntax
This commit is contained in:
parent
8f03d00dc0
commit
57362f6017
@ -0,0 +1,18 @@
|
||||
//// [a.js]
|
||||
|
||||
class c {
|
||||
method(a) {
|
||||
let x = a => this.method(a);
|
||||
}
|
||||
}
|
||||
|
||||
//// [out.js]
|
||||
var c = (function () {
|
||||
function c() {
|
||||
}
|
||||
c.prototype.method = function (a) {
|
||||
var _this = this;
|
||||
var x = function (a) { return _this.method(a); };
|
||||
};
|
||||
return c;
|
||||
})();
|
||||
@ -0,0 +1,18 @@
|
||||
=== tests/cases/compiler/a.js ===
|
||||
|
||||
class c {
|
||||
>c : Symbol(c, Decl(a.js, 0, 0))
|
||||
|
||||
method(a) {
|
||||
>method : Symbol(method, Decl(a.js, 1, 9))
|
||||
>a : Symbol(a, Decl(a.js, 2, 11))
|
||||
|
||||
let x = a => this.method(a);
|
||||
>x : Symbol(x, Decl(a.js, 3, 11))
|
||||
>a : Symbol(a, Decl(a.js, 3, 15))
|
||||
>this.method : Symbol(method, Decl(a.js, 1, 9))
|
||||
>this : Symbol(c, Decl(a.js, 0, 0))
|
||||
>method : Symbol(method, Decl(a.js, 1, 9))
|
||||
>a : Symbol(a, Decl(a.js, 3, 15))
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
=== tests/cases/compiler/a.js ===
|
||||
|
||||
class c {
|
||||
>c : c
|
||||
|
||||
method(a) {
|
||||
>method : (a: any) => void
|
||||
>a : any
|
||||
|
||||
let x = a => this.method(a);
|
||||
>x : (a: any) => void
|
||||
>a => this.method(a) : (a: any) => void
|
||||
>a : any
|
||||
>this.method(a) : void
|
||||
>this.method : (a: any) => void
|
||||
>this : this
|
||||
>method : (a: any) => void
|
||||
>a : any
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
//// [a.js]
|
||||
|
||||
function foo(a) {
|
||||
for (let a = 0; a < 10; a++) {
|
||||
// do something
|
||||
}
|
||||
}
|
||||
|
||||
//// [out.js]
|
||||
function foo(a) {
|
||||
for (var a_1 = 0; a_1 < 10; a_1++) {
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
=== tests/cases/compiler/a.js ===
|
||||
|
||||
function foo(a) {
|
||||
>foo : Symbol(foo, Decl(a.js, 0, 0))
|
||||
>a : Symbol(a, Decl(a.js, 1, 13))
|
||||
|
||||
for (let a = 0; a < 10; a++) {
|
||||
>a : Symbol(a, Decl(a.js, 2, 12))
|
||||
>a : Symbol(a, Decl(a.js, 2, 12))
|
||||
>a : Symbol(a, Decl(a.js, 2, 12))
|
||||
|
||||
// do something
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
=== tests/cases/compiler/a.js ===
|
||||
|
||||
function foo(a) {
|
||||
>foo : (a: any) => void
|
||||
>a : any
|
||||
|
||||
for (let a = 0; a < 10; a++) {
|
||||
>a : number
|
||||
>0 : number
|
||||
>a < 10 : boolean
|
||||
>a : number
|
||||
>10 : number
|
||||
>a++ : number
|
||||
>a : number
|
||||
|
||||
// do something
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
//// [a.js]
|
||||
|
||||
function foo() {
|
||||
var a = 10;
|
||||
var b = "Hello";
|
||||
return {
|
||||
a,
|
||||
b
|
||||
};
|
||||
}
|
||||
|
||||
//// [out.js]
|
||||
function foo() {
|
||||
var a = 10;
|
||||
var b = "Hello";
|
||||
return {
|
||||
a: a,
|
||||
b: b
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
=== tests/cases/compiler/a.js ===
|
||||
|
||||
function foo() {
|
||||
>foo : Symbol(foo, Decl(a.js, 0, 0))
|
||||
|
||||
var a = 10;
|
||||
>a : Symbol(a, Decl(a.js, 2, 7))
|
||||
|
||||
var b = "Hello";
|
||||
>b : Symbol(b, Decl(a.js, 3, 7))
|
||||
|
||||
return {
|
||||
a,
|
||||
>a : Symbol(a, Decl(a.js, 4, 12))
|
||||
|
||||
b
|
||||
>b : Symbol(b, Decl(a.js, 5, 10))
|
||||
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
=== tests/cases/compiler/a.js ===
|
||||
|
||||
function foo() {
|
||||
>foo : () => { a: number; b: string; }
|
||||
|
||||
var a = 10;
|
||||
>a : number
|
||||
>10 : number
|
||||
|
||||
var b = "Hello";
|
||||
>b : string
|
||||
>"Hello" : string
|
||||
|
||||
return {
|
||||
>{ a, b } : { a: number; b: string; }
|
||||
|
||||
a,
|
||||
>a : number
|
||||
|
||||
b
|
||||
>b : string
|
||||
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
// @jsExtensions: js
|
||||
// @out: out.js
|
||||
|
||||
// @FileName: a.js
|
||||
class c {
|
||||
method(a) {
|
||||
let x = a => this.method(a);
|
||||
}
|
||||
}
|
||||
9
tests/cases/compiler/jsFileCompilationLetBeingRenamed.ts
Normal file
9
tests/cases/compiler/jsFileCompilationLetBeingRenamed.ts
Normal file
@ -0,0 +1,9 @@
|
||||
// @jsExtensions: js
|
||||
// @out: out.js
|
||||
|
||||
// @FileName: a.js
|
||||
function foo(a) {
|
||||
for (let a = 0; a < 10; a++) {
|
||||
// do something
|
||||
}
|
||||
}
|
||||
12
tests/cases/compiler/jsFileCompilationShortHandProperty.ts
Normal file
12
tests/cases/compiler/jsFileCompilationShortHandProperty.ts
Normal file
@ -0,0 +1,12 @@
|
||||
// @jsExtensions: js
|
||||
// @out: out.js
|
||||
|
||||
// @FileName: a.js
|
||||
function foo() {
|
||||
var a = 10;
|
||||
var b = "Hello";
|
||||
return {
|
||||
a,
|
||||
b
|
||||
};
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user