Skip to content

Commit f330a7e

Browse files
authored
Merge pull request #13220 from Microsoft/mergeMaster1229
Merge master 12/29
2 parents 708f9e5 + cc306f6 commit f330a7e

10 files changed

+514
-3
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference path="moduleNameResolver.ts"/>
1+
/// <reference path="moduleNameResolver.ts"/>
22
/// <reference path="binder.ts"/>
33

44
/* @internal */
@@ -17233,7 +17233,7 @@ namespace ts {
1723317233
}
1723417234

1723517235
if (node.kind === SyntaxKind.BindingElement) {
17236-
if (node.parent.kind === SyntaxKind.ObjectBindingPattern && languageVersion < ScriptTarget.ESNext) {
17236+
if (node.parent.kind === SyntaxKind.ObjectBindingPattern && languageVersion < ScriptTarget.ESNext && !isInAmbientContext(node)) {
1723717237
checkExternalEmitHelpers(node, ExternalEmitHelpers.Rest);
1723817238
}
1723917239
// check computed properties inside property names of binding elements

src/compiler/visitor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ namespace ts {
13281328
function aggregateTransformFlagsForSubtree(node: Node): TransformFlags {
13291329
// We do not transform ambient declarations or types, so there is no need to
13301330
// recursively aggregate transform flags.
1331-
if (hasModifier(node, ModifierFlags.Ambient) || isTypeNode(node)) {
1331+
if (hasModifier(node, ModifierFlags.Ambient) || (isTypeNode(node) && node.kind !== SyntaxKind.ExpressionWithTypeArguments)) {
13321332
return TransformFlags.None;
13331333
}
13341334

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//// [tests/cases/compiler/importHelpersInAmbientContext.ts] ////
2+
3+
//// [a.d.ts]
4+
5+
export { };
6+
7+
// Extends
8+
declare class C { }
9+
declare class D extends C { }
10+
11+
// Destructuring
12+
interface I {
13+
({descendants, read}?: {
14+
descendants?: boolean;
15+
read?: any;
16+
}): any;
17+
}
18+
19+
20+
// Object Rest
21+
interface Foo {
22+
a: number; b: string;
23+
}
24+
export var { a, ...x } : Foo;
25+
26+
//// [b.ts]
27+
export {};
28+
declare namespace N {
29+
// Extends
30+
class C { }
31+
class D extends C { }
32+
33+
// Destructuring
34+
interface I {
35+
({descendants, read}?: {
36+
descendants?: boolean;
37+
read?: any;
38+
}): any;
39+
}
40+
41+
42+
// Object Rest
43+
interface Foo {
44+
a: number; b: string;
45+
}
46+
export var { a, ...x } : Foo;
47+
}
48+
49+
//// [tslib.d.ts]
50+
export declare function __extends(d: Function, b: Function): void;
51+
export declare function __assign(t: any, ...sources: any[]): any;
52+
export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any;
53+
export declare function __param(paramIndex: number, decorator: Function): Function;
54+
export declare function __metadata(metadataKey: any, metadataValue: any): Function;
55+
export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any;
56+
57+
58+
//// [b.js]
59+
"use strict";
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
=== tests/cases/compiler/a.d.ts ===
2+
3+
export { };
4+
5+
// Extends
6+
declare class C { }
7+
>C : Symbol(C, Decl(a.d.ts, 1, 11))
8+
9+
declare class D extends C { }
10+
>D : Symbol(D, Decl(a.d.ts, 4, 19))
11+
>C : Symbol(C, Decl(a.d.ts, 1, 11))
12+
13+
// Destructuring
14+
interface I {
15+
>I : Symbol(I, Decl(a.d.ts, 5, 29))
16+
17+
({descendants, read}?: {
18+
>descendants : Symbol(descendants, Decl(a.d.ts, 9, 6))
19+
>read : Symbol(read, Decl(a.d.ts, 9, 18))
20+
21+
descendants?: boolean;
22+
>descendants : Symbol(descendants, Decl(a.d.ts, 9, 28))
23+
24+
read?: any;
25+
>read : Symbol(read, Decl(a.d.ts, 10, 30))
26+
27+
}): any;
28+
}
29+
30+
31+
// Object Rest
32+
interface Foo {
33+
>Foo : Symbol(Foo, Decl(a.d.ts, 13, 1))
34+
35+
a: number; b: string;
36+
>a : Symbol(Foo.a, Decl(a.d.ts, 17, 15))
37+
>b : Symbol(Foo.b, Decl(a.d.ts, 18, 14))
38+
}
39+
export var { a, ...x } : Foo;
40+
>a : Symbol(a, Decl(a.d.ts, 20, 12))
41+
>x : Symbol(x, Decl(a.d.ts, 20, 15))
42+
>Foo : Symbol(Foo, Decl(a.d.ts, 13, 1))
43+
44+
=== tests/cases/compiler/b.ts ===
45+
export {};
46+
declare namespace N {
47+
>N : Symbol(N, Decl(b.ts, 0, 10))
48+
49+
// Extends
50+
class C { }
51+
>C : Symbol(C, Decl(b.ts, 1, 21))
52+
53+
class D extends C { }
54+
>D : Symbol(D, Decl(b.ts, 3, 12))
55+
>C : Symbol(C, Decl(b.ts, 1, 21))
56+
57+
// Destructuring
58+
interface I {
59+
>I : Symbol(I, Decl(b.ts, 4, 22))
60+
61+
({descendants, read}?: {
62+
>descendants : Symbol(descendants, Decl(b.ts, 8, 4))
63+
>read : Symbol(read, Decl(b.ts, 8, 16))
64+
65+
descendants?: boolean;
66+
>descendants : Symbol(descendants, Decl(b.ts, 8, 26))
67+
68+
read?: any;
69+
>read : Symbol(read, Decl(b.ts, 9, 25))
70+
71+
}): any;
72+
}
73+
74+
75+
// Object Rest
76+
interface Foo {
77+
>Foo : Symbol(Foo, Decl(b.ts, 12, 2))
78+
79+
a: number; b: string;
80+
>a : Symbol(Foo.a, Decl(b.ts, 16, 16))
81+
>b : Symbol(Foo.b, Decl(b.ts, 17, 12))
82+
}
83+
export var { a, ...x } : Foo;
84+
>a : Symbol(a, Decl(b.ts, 19, 13))
85+
>x : Symbol(x, Decl(b.ts, 19, 16))
86+
>Foo : Symbol(Foo, Decl(b.ts, 12, 2))
87+
}
88+
89+
=== tests/cases/compiler/tslib.d.ts ===
90+
export declare function __extends(d: Function, b: Function): void;
91+
>__extends : Symbol(__extends, Decl(tslib.d.ts, --, --))
92+
>d : Symbol(d, Decl(tslib.d.ts, --, --))
93+
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
94+
>b : Symbol(b, Decl(tslib.d.ts, --, --))
95+
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
96+
97+
export declare function __assign(t: any, ...sources: any[]): any;
98+
>__assign : Symbol(__assign, Decl(tslib.d.ts, --, --))
99+
>t : Symbol(t, Decl(tslib.d.ts, --, --))
100+
>sources : Symbol(sources, Decl(tslib.d.ts, --, --))
101+
102+
export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any;
103+
>__decorate : Symbol(__decorate, Decl(tslib.d.ts, --, --))
104+
>decorators : Symbol(decorators, Decl(tslib.d.ts, --, --))
105+
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
106+
>target : Symbol(target, Decl(tslib.d.ts, --, --))
107+
>key : Symbol(key, Decl(tslib.d.ts, --, --))
108+
>desc : Symbol(desc, Decl(tslib.d.ts, --, --))
109+
110+
export declare function __param(paramIndex: number, decorator: Function): Function;
111+
>__param : Symbol(__param, Decl(tslib.d.ts, --, --))
112+
>paramIndex : Symbol(paramIndex, Decl(tslib.d.ts, --, --))
113+
>decorator : Symbol(decorator, Decl(tslib.d.ts, --, --))
114+
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
115+
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
116+
117+
export declare function __metadata(metadataKey: any, metadataValue: any): Function;
118+
>__metadata : Symbol(__metadata, Decl(tslib.d.ts, --, --))
119+
>metadataKey : Symbol(metadataKey, Decl(tslib.d.ts, --, --))
120+
>metadataValue : Symbol(metadataValue, Decl(tslib.d.ts, --, --))
121+
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
122+
123+
export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any;
124+
>__awaiter : Symbol(__awaiter, Decl(tslib.d.ts, --, --))
125+
>thisArg : Symbol(thisArg, Decl(tslib.d.ts, --, --))
126+
>_arguments : Symbol(_arguments, Decl(tslib.d.ts, --, --))
127+
>P : Symbol(P, Decl(tslib.d.ts, --, --))
128+
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
129+
>generator : Symbol(generator, Decl(tslib.d.ts, --, --))
130+
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
131+
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
=== tests/cases/compiler/a.d.ts ===
2+
3+
export { };
4+
5+
// Extends
6+
declare class C { }
7+
>C : C
8+
9+
declare class D extends C { }
10+
>D : D
11+
>C : C
12+
13+
// Destructuring
14+
interface I {
15+
>I : I
16+
17+
({descendants, read}?: {
18+
>descendants : boolean
19+
>read : any
20+
21+
descendants?: boolean;
22+
>descendants : boolean
23+
24+
read?: any;
25+
>read : any
26+
27+
}): any;
28+
}
29+
30+
31+
// Object Rest
32+
interface Foo {
33+
>Foo : Foo
34+
35+
a: number; b: string;
36+
>a : number
37+
>b : string
38+
}
39+
export var { a, ...x } : Foo;
40+
>a : number
41+
>x : { b: string; }
42+
>Foo : Foo
43+
44+
=== tests/cases/compiler/b.ts ===
45+
export {};
46+
declare namespace N {
47+
>N : typeof N
48+
49+
// Extends
50+
class C { }
51+
>C : C
52+
53+
class D extends C { }
54+
>D : D
55+
>C : C
56+
57+
// Destructuring
58+
interface I {
59+
>I : I
60+
61+
({descendants, read}?: {
62+
>descendants : boolean
63+
>read : any
64+
65+
descendants?: boolean;
66+
>descendants : boolean
67+
68+
read?: any;
69+
>read : any
70+
71+
}): any;
72+
}
73+
74+
75+
// Object Rest
76+
interface Foo {
77+
>Foo : Foo
78+
79+
a: number; b: string;
80+
>a : number
81+
>b : string
82+
}
83+
export var { a, ...x } : Foo;
84+
>a : number
85+
>x : { b: string; }
86+
>Foo : Foo
87+
}
88+
89+
=== tests/cases/compiler/tslib.d.ts ===
90+
export declare function __extends(d: Function, b: Function): void;
91+
>__extends : (d: Function, b: Function) => void
92+
>d : Function
93+
>Function : Function
94+
>b : Function
95+
>Function : Function
96+
97+
export declare function __assign(t: any, ...sources: any[]): any;
98+
>__assign : (t: any, ...sources: any[]) => any
99+
>t : any
100+
>sources : any[]
101+
102+
export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any;
103+
>__decorate : (decorators: Function[], target: any, key?: string | symbol, desc?: any) => any
104+
>decorators : Function[]
105+
>Function : Function
106+
>target : any
107+
>key : string | symbol
108+
>desc : any
109+
110+
export declare function __param(paramIndex: number, decorator: Function): Function;
111+
>__param : (paramIndex: number, decorator: Function) => Function
112+
>paramIndex : number
113+
>decorator : Function
114+
>Function : Function
115+
>Function : Function
116+
117+
export declare function __metadata(metadataKey: any, metadataValue: any): Function;
118+
>__metadata : (metadataKey: any, metadataValue: any) => Function
119+
>metadataKey : any
120+
>metadataValue : any
121+
>Function : Function
122+
123+
export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any;
124+
>__awaiter : (thisArg: any, _arguments: any, P: Function, generator: Function) => any
125+
>thisArg : any
126+
>_arguments : any
127+
>P : Function
128+
>Function : Function
129+
>generator : Function
130+
>Function : Function
131+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//// [jsxInExtendsClause.tsx]
2+
// https://github.com/Microsoft/TypeScript/issues/13157
3+
declare namespace React {
4+
interface ComponentClass<P> { new (): Component<P, {}>; }
5+
class Component<A, B> {}
6+
}
7+
declare function createComponentClass<P>(factory: () => React.ComponentClass<P>): React.ComponentClass<P>;
8+
class Foo extends createComponentClass(() => class extends React.Component<{}, {}> {
9+
render() {
10+
return <span>Hello, world!</span>;
11+
}
12+
}) {}
13+
14+
//// [jsxInExtendsClause.js]
15+
var __extends = (this && this.__extends) || function (d, b) {
16+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
17+
function __() { this.constructor = d; }
18+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19+
};
20+
var Foo = (function (_super) {
21+
__extends(Foo, _super);
22+
function Foo() {
23+
return _super.apply(this, arguments) || this;
24+
}
25+
return Foo;
26+
}(createComponentClass(function () { return (function (_super) {
27+
__extends(class_1, _super);
28+
function class_1() {
29+
return _super.apply(this, arguments) || this;
30+
}
31+
class_1.prototype.render = function () {
32+
return React.createElement("span", null, "Hello, world!");
33+
};
34+
return class_1;
35+
}(React.Component)); })));

0 commit comments

Comments
 (0)