Merge pull request #12781 from Microsoft/mergeMaster1208

Merge master 12/08
This commit is contained in:
Mohamed Hegazy 2016-12-08 16:25:32 -08:00 committed by GitHub
commit a350b8c094
9 changed files with 253 additions and 3 deletions

View File

@ -16199,7 +16199,7 @@ namespace ts {
return undefined;
}
const onfulfilledParameterType = getTypeWithFacts(getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)), TypeFacts.NEUndefined);
const onfulfilledParameterType = getTypeWithFacts(getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)), TypeFacts.NEUndefinedOrNull);
if (isTypeAny(onfulfilledParameterType)) {
return undefined;
}

View File

@ -1223,11 +1223,12 @@ namespace ts {
}
const { firstAccessor, secondAccessor, setAccessor } = getAllAccessorDeclarations(node.members, accessor);
if (accessor !== firstAccessor) {
const firstAccessorWithDecorators = firstAccessor.decorators ? firstAccessor : secondAccessor && secondAccessor.decorators ? secondAccessor : undefined;
if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) {
return undefined;
}
const decorators = firstAccessor.decorators || (secondAccessor && secondAccessor.decorators);
const decorators = firstAccessorWithDecorators.decorators;
const parameters = getDecoratorsOfParameters(setAccessor);
if (!decorators && !parameters) {
return undefined;

View File

@ -0,0 +1,11 @@
//// [awaitInheritedPromise_es2017.ts]
interface A extends Promise<string> {}
declare var a: A;
async function f() {
await a;
}
//// [awaitInheritedPromise_es2017.js]
async function f() {
await a;
}

View File

@ -0,0 +1,15 @@
=== tests/cases/conformance/async/es2017/awaitInheritedPromise_es2017.ts ===
interface A extends Promise<string> {}
>A : Symbol(A, Decl(awaitInheritedPromise_es2017.ts, 0, 0))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
declare var a: A;
>a : Symbol(a, Decl(awaitInheritedPromise_es2017.ts, 1, 11))
>A : Symbol(A, Decl(awaitInheritedPromise_es2017.ts, 0, 0))
async function f() {
>f : Symbol(f, Decl(awaitInheritedPromise_es2017.ts, 1, 17))
await a;
>a : Symbol(a, Decl(awaitInheritedPromise_es2017.ts, 1, 11))
}

View File

@ -0,0 +1,16 @@
=== tests/cases/conformance/async/es2017/awaitInheritedPromise_es2017.ts ===
interface A extends Promise<string> {}
>A : A
>Promise : Promise<T>
declare var a: A;
>a : A
>A : A
async function f() {
>f : () => Promise<void>
await a;
>await a : string
>a : A
}

View File

@ -0,0 +1,41 @@
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor7.ts(26,5): error TS1207: Decorators cannot be applied to multiple get/set accessors of the same name.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor7.ts(31,5): error TS1207: Decorators cannot be applied to multiple get/set accessors of the same name.
==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor7.ts (2 errors) ====
declare function dec1<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
declare function dec2<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class A {
@dec1 get x() { return 0; }
set x(value: number) { }
}
class B {
get x() { return 0; }
@dec2 set x(value: number) { }
}
class C {
@dec1 set x(value: number) { }
get x() { return 0; }
}
class D {
set x(value: number) { }
@dec2 get x() { return 0; }
}
class E {
@dec1 get x() { return 0; }
@dec2 set x(value: number) { }
~
!!! error TS1207: Decorators cannot be applied to multiple get/set accessors of the same name.
}
class F {
@dec1 set x(value: number) { }
@dec2 get x() { return 0; }
~
!!! error TS1207: Decorators cannot be applied to multiple get/set accessors of the same name.
}

View File

@ -0,0 +1,125 @@
//// [decoratorOnClassAccessor7.ts]
declare function dec1<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
declare function dec2<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class A {
@dec1 get x() { return 0; }
set x(value: number) { }
}
class B {
get x() { return 0; }
@dec2 set x(value: number) { }
}
class C {
@dec1 set x(value: number) { }
get x() { return 0; }
}
class D {
set x(value: number) { }
@dec2 get x() { return 0; }
}
class E {
@dec1 get x() { return 0; }
@dec2 set x(value: number) { }
}
class F {
@dec1 set x(value: number) { }
@dec2 get x() { return 0; }
}
//// [decoratorOnClassAccessor7.js]
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var A = (function () {
function A() {
}
Object.defineProperty(A.prototype, "x", {
get: function () { return 0; },
set: function (value) { },
enumerable: true,
configurable: true
});
return A;
}());
__decorate([
dec1
], A.prototype, "x", null);
var B = (function () {
function B() {
}
Object.defineProperty(B.prototype, "x", {
get: function () { return 0; },
set: function (value) { },
enumerable: true,
configurable: true
});
return B;
}());
__decorate([
dec2
], B.prototype, "x", null);
var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "x", {
get: function () { return 0; },
set: function (value) { },
enumerable: true,
configurable: true
});
return C;
}());
__decorate([
dec1
], C.prototype, "x", null);
var D = (function () {
function D() {
}
Object.defineProperty(D.prototype, "x", {
get: function () { return 0; },
set: function (value) { },
enumerable: true,
configurable: true
});
return D;
}());
__decorate([
dec2
], D.prototype, "x", null);
var E = (function () {
function E() {
}
Object.defineProperty(E.prototype, "x", {
get: function () { return 0; },
set: function (value) { },
enumerable: true,
configurable: true
});
return E;
}());
__decorate([
dec1
], E.prototype, "x", null);
var F = (function () {
function F() {
}
Object.defineProperty(F.prototype, "x", {
get: function () { return 0; },
set: function (value) { },
enumerable: true,
configurable: true
});
return F;
}());
__decorate([
dec1
], F.prototype, "x", null);

View File

@ -0,0 +1,7 @@
// @target: es2017
// @strictNullChecks: true
interface A extends Promise<string> {}
declare var a: A;
async function f() {
await a;
}

View File

@ -0,0 +1,34 @@
// @target:es5
// @experimentaldecorators: true
declare function dec1<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
declare function dec2<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class A {
@dec1 get x() { return 0; }
set x(value: number) { }
}
class B {
get x() { return 0; }
@dec2 set x(value: number) { }
}
class C {
@dec1 set x(value: number) { }
get x() { return 0; }
}
class D {
set x(value: number) { }
@dec2 get x() { return 0; }
}
class E {
@dec1 get x() { return 0; }
@dec2 set x(value: number) { }
}
class F {
@dec1 set x(value: number) { }
@dec2 get x() { return 0; }
}