mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-31 18:10:56 -05:00
Merge branch 'master' into object-spread
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
// @target: es5
|
||||
// @sourcemap: true
|
||||
|
||||
class C {
|
||||
cProp = 10;
|
||||
|
||||
foo() { return "this never gets used."; }
|
||||
|
||||
constructor(value: number) {
|
||||
return {
|
||||
cProp: value,
|
||||
foo() {
|
||||
return "well this looks kinda C-ish.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class D extends C {
|
||||
dProp = () => this;
|
||||
|
||||
constructor(a = 100) {
|
||||
super(a);
|
||||
|
||||
if (Math.random() < 0.5) {
|
||||
"You win!"
|
||||
return {
|
||||
cProp: 1,
|
||||
dProp: () => this,
|
||||
foo() { return "You win!!!!!" }
|
||||
};
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
39
tests/cases/compiler/es6modulekindWithES5Target12.ts
Normal file
39
tests/cases/compiler/es6modulekindWithES5Target12.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
// @target: es5
|
||||
// @module: es2015
|
||||
|
||||
export class C {
|
||||
}
|
||||
|
||||
export namespace C {
|
||||
export const x = 1;
|
||||
}
|
||||
|
||||
export enum E {
|
||||
w = 1
|
||||
}
|
||||
|
||||
export enum E {
|
||||
x = 2
|
||||
}
|
||||
|
||||
export namespace E {
|
||||
export const y = 1;
|
||||
}
|
||||
|
||||
export namespace E {
|
||||
export const z = 1;
|
||||
}
|
||||
|
||||
export namespace N {
|
||||
}
|
||||
|
||||
export namespace N {
|
||||
export const x = 1;
|
||||
}
|
||||
|
||||
export function F() {
|
||||
}
|
||||
|
||||
export namespace F {
|
||||
export const x = 1;
|
||||
}
|
||||
2
tests/cases/compiler/exportInFunction.ts
Normal file
2
tests/cases/compiler/exportInFunction.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
function f() {
|
||||
export = 0;
|
||||
@@ -0,0 +1,8 @@
|
||||
// @target: es5
|
||||
|
||||
// https://github.com/Microsoft/TypeScript/issues/11236
|
||||
while (true)
|
||||
{
|
||||
let local = null;
|
||||
var a = () => local; // <-- Lambda should be converted to function()
|
||||
}
|
||||
23
tests/cases/compiler/underscoreThisInDerivedClass01.ts
Normal file
23
tests/cases/compiler/underscoreThisInDerivedClass01.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
// @target es5
|
||||
|
||||
// Original test intent:
|
||||
// When arrow functions capture 'this', the lexical 'this' owner
|
||||
// currently captures 'this' using a variable named '_this'.
|
||||
// That means that '_this' becomes a reserved identifier in certain places.
|
||||
//
|
||||
// Constructors have adopted the same identifier name ('_this')
|
||||
// for capturing any potential return values from super calls,
|
||||
// so we expect the same behavior.
|
||||
|
||||
class C {
|
||||
constructor() {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
class D extends C {
|
||||
constructor() {
|
||||
var _this = "uh-oh?";
|
||||
super();
|
||||
}
|
||||
}
|
||||
17
tests/cases/compiler/underscoreThisInDerivedClass02.ts
Normal file
17
tests/cases/compiler/underscoreThisInDerivedClass02.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
// @target es5
|
||||
|
||||
// Original test intent:
|
||||
// Errors on '_this' should be reported in derived constructors,
|
||||
// even if 'super()' is not called.
|
||||
|
||||
class C {
|
||||
constructor() {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
class D extends C {
|
||||
constructor() {
|
||||
var _this = "uh-oh?";
|
||||
}
|
||||
}
|
||||
14
tests/cases/compiler/unreachableFlowAfterFinally.ts
Normal file
14
tests/cases/compiler/unreachableFlowAfterFinally.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
// @noImplicitReturns: true
|
||||
|
||||
function f() {
|
||||
let x = 100;
|
||||
try {
|
||||
throw "WAT"
|
||||
}
|
||||
catch (e) {
|
||||
|
||||
}
|
||||
finally {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user