Skip to content

Commit a350b8c

Browse files
authored
Merge pull request #12781 from Microsoft/mergeMaster1208
Merge master 12/08
2 parents f1d7a8a + 650752c commit a350b8c

File tree

9 files changed

+253
-3
lines changed

9 files changed

+253
-3
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16199,7 +16199,7 @@ namespace ts {
1619916199
return undefined;
1620016200
}
1620116201

16202-
const onfulfilledParameterType = getTypeWithFacts(getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)), TypeFacts.NEUndefined);
16202+
const onfulfilledParameterType = getTypeWithFacts(getUnionType(map(thenSignatures, getTypeOfFirstParameterOfSignature)), TypeFacts.NEUndefinedOrNull);
1620316203
if (isTypeAny(onfulfilledParameterType)) {
1620416204
return undefined;
1620516205
}

src/compiler/transformers/ts.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,11 +1223,12 @@ namespace ts {
12231223
}
12241224

12251225
const { firstAccessor, secondAccessor, setAccessor } = getAllAccessorDeclarations(node.members, accessor);
1226-
if (accessor !== firstAccessor) {
1226+
const firstAccessorWithDecorators = firstAccessor.decorators ? firstAccessor : secondAccessor && secondAccessor.decorators ? secondAccessor : undefined;
1227+
if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) {
12271228
return undefined;
12281229
}
12291230

1230-
const decorators = firstAccessor.decorators || (secondAccessor && secondAccessor.decorators);
1231+
const decorators = firstAccessorWithDecorators.decorators;
12311232
const parameters = getDecoratorsOfParameters(setAccessor);
12321233
if (!decorators && !parameters) {
12331234
return undefined;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//// [awaitInheritedPromise_es2017.ts]
2+
interface A extends Promise<string> {}
3+
declare var a: A;
4+
async function f() {
5+
await a;
6+
}
7+
8+
//// [awaitInheritedPromise_es2017.js]
9+
async function f() {
10+
await a;
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
=== tests/cases/conformance/async/es2017/awaitInheritedPromise_es2017.ts ===
2+
interface A extends Promise<string> {}
3+
>A : Symbol(A, Decl(awaitInheritedPromise_es2017.ts, 0, 0))
4+
>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, --, --))
5+
6+
declare var a: A;
7+
>a : Symbol(a, Decl(awaitInheritedPromise_es2017.ts, 1, 11))
8+
>A : Symbol(A, Decl(awaitInheritedPromise_es2017.ts, 0, 0))
9+
10+
async function f() {
11+
>f : Symbol(f, Decl(awaitInheritedPromise_es2017.ts, 1, 17))
12+
13+
await a;
14+
>a : Symbol(a, Decl(awaitInheritedPromise_es2017.ts, 1, 11))
15+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/conformance/async/es2017/awaitInheritedPromise_es2017.ts ===
2+
interface A extends Promise<string> {}
3+
>A : A
4+
>Promise : Promise<T>
5+
6+
declare var a: A;
7+
>a : A
8+
>A : A
9+
10+
async function f() {
11+
>f : () => Promise<void>
12+
13+
await a;
14+
>await a : string
15+
>a : A
16+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
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.
2+
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.
3+
4+
5+
==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor7.ts (2 errors) ====
6+
declare function dec1<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
7+
declare function dec2<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
8+
9+
class A {
10+
@dec1 get x() { return 0; }
11+
set x(value: number) { }
12+
}
13+
14+
class B {
15+
get x() { return 0; }
16+
@dec2 set x(value: number) { }
17+
}
18+
19+
class C {
20+
@dec1 set x(value: number) { }
21+
get x() { return 0; }
22+
}
23+
24+
class D {
25+
set x(value: number) { }
26+
@dec2 get x() { return 0; }
27+
}
28+
29+
class E {
30+
@dec1 get x() { return 0; }
31+
@dec2 set x(value: number) { }
32+
~
33+
!!! error TS1207: Decorators cannot be applied to multiple get/set accessors of the same name.
34+
}
35+
36+
class F {
37+
@dec1 set x(value: number) { }
38+
@dec2 get x() { return 0; }
39+
~
40+
!!! error TS1207: Decorators cannot be applied to multiple get/set accessors of the same name.
41+
}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
//// [decoratorOnClassAccessor7.ts]
2+
declare function dec1<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
3+
declare function dec2<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
4+
5+
class A {
6+
@dec1 get x() { return 0; }
7+
set x(value: number) { }
8+
}
9+
10+
class B {
11+
get x() { return 0; }
12+
@dec2 set x(value: number) { }
13+
}
14+
15+
class C {
16+
@dec1 set x(value: number) { }
17+
get x() { return 0; }
18+
}
19+
20+
class D {
21+
set x(value: number) { }
22+
@dec2 get x() { return 0; }
23+
}
24+
25+
class E {
26+
@dec1 get x() { return 0; }
27+
@dec2 set x(value: number) { }
28+
}
29+
30+
class F {
31+
@dec1 set x(value: number) { }
32+
@dec2 get x() { return 0; }
33+
}
34+
35+
//// [decoratorOnClassAccessor7.js]
36+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
37+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
38+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
39+
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;
40+
return c > 3 && r && Object.defineProperty(target, key, r), r;
41+
};
42+
var A = (function () {
43+
function A() {
44+
}
45+
Object.defineProperty(A.prototype, "x", {
46+
get: function () { return 0; },
47+
set: function (value) { },
48+
enumerable: true,
49+
configurable: true
50+
});
51+
return A;
52+
}());
53+
__decorate([
54+
dec1
55+
], A.prototype, "x", null);
56+
var B = (function () {
57+
function B() {
58+
}
59+
Object.defineProperty(B.prototype, "x", {
60+
get: function () { return 0; },
61+
set: function (value) { },
62+
enumerable: true,
63+
configurable: true
64+
});
65+
return B;
66+
}());
67+
__decorate([
68+
dec2
69+
], B.prototype, "x", null);
70+
var C = (function () {
71+
function C() {
72+
}
73+
Object.defineProperty(C.prototype, "x", {
74+
get: function () { return 0; },
75+
set: function (value) { },
76+
enumerable: true,
77+
configurable: true
78+
});
79+
return C;
80+
}());
81+
__decorate([
82+
dec1
83+
], C.prototype, "x", null);
84+
var D = (function () {
85+
function D() {
86+
}
87+
Object.defineProperty(D.prototype, "x", {
88+
get: function () { return 0; },
89+
set: function (value) { },
90+
enumerable: true,
91+
configurable: true
92+
});
93+
return D;
94+
}());
95+
__decorate([
96+
dec2
97+
], D.prototype, "x", null);
98+
var E = (function () {
99+
function E() {
100+
}
101+
Object.defineProperty(E.prototype, "x", {
102+
get: function () { return 0; },
103+
set: function (value) { },
104+
enumerable: true,
105+
configurable: true
106+
});
107+
return E;
108+
}());
109+
__decorate([
110+
dec1
111+
], E.prototype, "x", null);
112+
var F = (function () {
113+
function F() {
114+
}
115+
Object.defineProperty(F.prototype, "x", {
116+
get: function () { return 0; },
117+
set: function (value) { },
118+
enumerable: true,
119+
configurable: true
120+
});
121+
return F;
122+
}());
123+
__decorate([
124+
dec1
125+
], F.prototype, "x", null);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// @target: es2017
2+
// @strictNullChecks: true
3+
interface A extends Promise<string> {}
4+
declare var a: A;
5+
async function f() {
6+
await a;
7+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// @target:es5
2+
// @experimentaldecorators: true
3+
declare function dec1<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
4+
declare function dec2<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
5+
6+
class A {
7+
@dec1 get x() { return 0; }
8+
set x(value: number) { }
9+
}
10+
11+
class B {
12+
get x() { return 0; }
13+
@dec2 set x(value: number) { }
14+
}
15+
16+
class C {
17+
@dec1 set x(value: number) { }
18+
get x() { return 0; }
19+
}
20+
21+
class D {
22+
set x(value: number) { }
23+
@dec2 get x() { return 0; }
24+
}
25+
26+
class E {
27+
@dec1 get x() { return 0; }
28+
@dec2 set x(value: number) { }
29+
}
30+
31+
class F {
32+
@dec1 set x(value: number) { }
33+
@dec2 get x() { return 0; }
34+
}

0 commit comments

Comments
 (0)