Skip to content

Commit 06888e8

Browse files
committed
Merge branch 'master' into noImplicitAnyOnCast
Conflicts: src/compiler/checker.ts tests/baselines/reference/arrayCast.errors.txt tests/baselines/reference/contextualTyping39.errors.txt tests/baselines/reference/contextualTyping41.errors.txt tests/baselines/reference/fuzzy.errors.txt tests/baselines/reference/genericTypeAssertions2.errors.txt tests/baselines/reference/genericTypeAssertions4.errors.txt tests/baselines/reference/genericTypeAssertions5.errors.txt tests/baselines/reference/intTypeCheck.errors.txt tests/baselines/reference/typeAssertions.errors.txt
2 parents dd3bb9c + 9adb893 commit 06888e8

File tree

215 files changed

+3729
-3703
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+3729
-3703
lines changed
Binary file not shown.
Binary file not shown.
445 Bytes
Binary file not shown.
483 Bytes
Binary file not shown.

src/compiler/checker.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -4329,8 +4329,9 @@ module ts {
43294329
var exprType = checkExpression(node.operand);
43304330
var targetType = getTypeFromTypeNode(node.type);
43314331
if (fullTypeCheck && targetType !== unknownType) {
4332-
if (!isTypeAssignableTo(exprType, targetType)) {
4333-
checkTypeAssignableTo(targetType, getWidenedType(exprType, /*supressNoImplicitAnyErrors*/ true), node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other_Colon, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other);
4332+
var widenedType = getWidenedType(exprType, /*supressNoImplicitAnyErrors*/ true);
4333+
if (!(isTypeAssignableTo(targetType, widenedType))) {
4334+
checkTypeAssignableTo(exprType, targetType, node, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other_Colon, Diagnostics.Neither_type_0_nor_type_1_is_assignable_to_the_other);
43344335
}
43354336
}
43364337
return targetType;

src/compiler/emitter.ts

+10-19
Original file line numberDiff line numberDiff line change
@@ -1755,16 +1755,13 @@ module ts {
17551755
if (!isInstantiated(node)) {
17561756
return emitPinnedOrTripleSlashComments(node);
17571757
}
1758-
17591758
emitLeadingComments(node);
1760-
if (!(node.flags & NodeFlags.Export)) {
1761-
emitStart(node);
1762-
write("var ");
1763-
emit(node.name);
1764-
write(";");
1765-
emitEnd(node);
1766-
writeLine();
1767-
}
1759+
emitStart(node);
1760+
write("var ");
1761+
emit(node.name);
1762+
write(";");
1763+
emitEnd(node);
1764+
writeLine();
17681765
emitStart(node);
17691766
write("(function (");
17701767
emitStart(node.name);
@@ -1788,21 +1785,15 @@ module ts {
17881785
scopeEmitEnd();
17891786
}
17901787
write(")(");
1788+
if (node.flags & NodeFlags.Export) {
1789+
emit(node.name);
1790+
write(" = ");
1791+
}
17911792
emitModuleMemberName(node);
17921793
write(" || (");
17931794
emitModuleMemberName(node);
17941795
write(" = {}));");
17951796
emitEnd(node);
1796-
if (node.flags & NodeFlags.Export) {
1797-
writeLine();
1798-
emitStart(node);
1799-
write("var ");
1800-
emit(node.name);
1801-
write(" = ");
1802-
emitModuleMemberName(node);
1803-
emitEnd(node);
1804-
write(";");
1805-
}
18061797
emitTrailingComments(node);
18071798
}
18081799

src/harness/fourslash.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,8 @@ module FourSlash {
10841084
// Make the edit
10851085
var ch = text.charAt(i);
10861086
this.languageServiceShimHost.editScript(this.activeFile.fileName, offset, offset, ch);
1087+
this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, offset);
1088+
10871089
this.updateMarkersForEdit(this.activeFile.fileName, offset, offset, ch);
10881090
this.editCheckpoint(this.activeFile.fileName);
10891091
offset++;

src/lib/dom.generated.d.ts

+43-43
Original file line numberDiff line numberDiff line change
@@ -1865,30 +1865,25 @@ declare var Window: {
18651865
new(): Window;
18661866
}
18671867

1868-
interface FormData {
1869-
append(name: any, value: any, blobName?: string): void;
1870-
}
1871-
declare var FormData: {
1872-
prototype: FormData;
1873-
new (form?: HTMLFormElement): FormData;
1874-
}
1875-
1876-
interface SourceBuffer extends EventTarget {
1877-
updating: boolean;
1878-
appendWindowStart: number;
1879-
appendWindowEnd: number;
1880-
buffered: TimeRanges;
1881-
timestampOffset: number;
1882-
audioTracks: AudioTrackList;
1883-
appendBuffer(data: ArrayBufferView): void;
1884-
appendBuffer(data: ArrayBuffer): void;
1885-
remove(start: number, end: number): void;
1886-
abort(): void;
1887-
appendStream(stream: MSStream, maxSize?: number): void;
1868+
interface HTMLCollection extends MSHTMLCollectionExtensions {
1869+
/**
1870+
* Sets or retrieves the number of objects in a collection.
1871+
*/
1872+
length: number;
1873+
/**
1874+
* Retrieves an object from various collections.
1875+
*/
1876+
item(nameOrIndex?: any, optionalIndex?: any): Element;
1877+
/**
1878+
* Retrieves a select object or an object from an options collection.
1879+
*/
1880+
namedItem(name: string): Element;
1881+
// [name: string]: Element;
1882+
[index: number]: Element;
18881883
}
1889-
declare var SourceBuffer: {
1890-
prototype: SourceBuffer;
1891-
new(): SourceBuffer;
1884+
declare var HTMLCollection: {
1885+
prototype: HTMLCollection;
1886+
new(): HTMLCollection;
18921887
}
18931888

18941889
interface NavigatorID {
@@ -3797,26 +3792,6 @@ declare var MSCSSProperties: {
37973792
new(): MSCSSProperties;
37983793
}
37993794

3800-
interface HTMLCollection extends MSHTMLCollectionExtensions {
3801-
/**
3802-
* Sets or retrieves the number of objects in a collection.
3803-
*/
3804-
length: number;
3805-
/**
3806-
* Retrieves an object from various collections.
3807-
*/
3808-
item(nameOrIndex?: any, optionalIndex?: any): Element;
3809-
/**
3810-
* Retrieves a select object or an object from an options collection.
3811-
*/
3812-
namedItem(name: string): Element;
3813-
// [name: string]: Element;
3814-
}
3815-
declare var HTMLCollection: {
3816-
prototype: HTMLCollection;
3817-
new(): HTMLCollection;
3818-
}
3819-
38203795
interface SVGExternalResourcesRequired {
38213796
externalResourcesRequired: SVGAnimatedBoolean;
38223797
}
@@ -10222,6 +10197,14 @@ declare var MSManipulationEvent: {
1022210197
MS_MANIPULATION_STATE_CANCELLED: number;
1022310198
}
1022410199

10200+
interface FormData {
10201+
append(name: any, value: any, blobName?: string): void;
10202+
}
10203+
declare var FormData: {
10204+
prototype: FormData;
10205+
new(): FormData;
10206+
}
10207+
1022510208
interface HTMLDataListElement extends HTMLElement {
1022610209
options: HTMLCollection;
1022710210
}
@@ -10640,6 +10623,23 @@ interface RandomSource {
1064010623
getRandomValues(array: ArrayBufferView): ArrayBufferView;
1064110624
}
1064210625

10626+
interface SourceBuffer extends EventTarget {
10627+
updating: boolean;
10628+
appendWindowStart: number;
10629+
appendWindowEnd: number;
10630+
buffered: TimeRanges;
10631+
timestampOffset: number;
10632+
audioTracks: AudioTrackList;
10633+
appendBuffer(data: ArrayBuffer): void;
10634+
remove(start: number, end: number): void;
10635+
abort(): void;
10636+
appendStream(stream: MSStream, maxSize?: number): void;
10637+
}
10638+
declare var SourceBuffer: {
10639+
prototype: SourceBuffer;
10640+
new(): SourceBuffer;
10641+
}
10642+
1064310643
interface MSInputMethodContext extends EventTarget {
1064410644
oncandidatewindowshow: (ev: any) => any;
1064510645
target: HTMLElement;

src/services/syntax/parser.ts

+19-8
Original file line numberDiff line numberDiff line change
@@ -544,18 +544,29 @@ module TypeScript.Parser {
544544
}
545545
}
546546

547-
function replaceTokenInParent(oldToken: ISyntaxToken, newToken: ISyntaxToken): void {
547+
function replaceTokenInParent(node: ISyntaxNode, oldToken: ISyntaxToken, newToken: ISyntaxToken): void {
548548
// oldToken may be parented by a node or a list.
549549
replaceTokenInParentWorker(oldToken, newToken);
550550

551551
var parent = oldToken.parent;
552552
newToken.parent = parent;
553553

554-
// Parent must be a list or a node. All of those have a 'data' element.
555-
Debug.assert(isNode(parent) || isList(parent) || isSeparatedList(parent));
556-
var dataElement = <{ data: number }><any>parent;
557-
if (dataElement.data) {
558-
dataElement.data &= SyntaxConstants.NodeParsedInStrictModeMask
554+
// Walk upwards to our outermost node, clearing hte cached 'data' in it. This will
555+
// make sure that the fullWidths and incrementally unusable bits are computed correctly
556+
// when next requested.
557+
while (true) {
558+
// Parent must be a list or a node. All of those have a 'data' element.
559+
Debug.assert(isNode(parent) || isList(parent) || isSeparatedList(parent));
560+
var dataElement = <{ data: number }><any>parent;
561+
if (dataElement.data) {
562+
dataElement.data &= SyntaxConstants.NodeParsedInStrictModeMask
563+
}
564+
565+
if (parent === node) {
566+
break;
567+
}
568+
569+
parent = parent.parent;
559570
}
560571
}
561572

@@ -602,7 +613,7 @@ module TypeScript.Parser {
602613
var oldToken = lastToken(node);
603614
var newToken = addSkippedTokenAfterToken(oldToken, skippedToken);
604615

605-
replaceTokenInParent(oldToken, newToken);
616+
replaceTokenInParent(node, oldToken, newToken);
606617
return node;
607618
}
608619

@@ -611,7 +622,7 @@ module TypeScript.Parser {
611622
var oldToken = firstToken(node);
612623
var newToken = addSkippedTokensBeforeToken(oldToken, skippedTokens);
613624

614-
replaceTokenInParent(oldToken, newToken);
625+
replaceTokenInParent(node, oldToken, newToken);
615626
}
616627

617628
return node;

tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ var A;
5353
return Point;
5454
})();
5555
A.Point = Point;
56+
var Point;
5657
(function (Point) {
5758
function Origin() {
5859
return "";
5960
}
6061
Point.Origin = Origin; //expected duplicate identifier error
61-
})(A.Point || (A.Point = {}));
62-
var Point = A.Point;
62+
})(Point = A.Point || (A.Point = {}));
6363
})(A || (A = {}));

tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ var A;
5252
return Point;
5353
})();
5454
A.Point = Point;
55+
var Point;
5556
(function (Point) {
5657
function Origin() {
5758
return "";
5859
} // not an error since not exported
59-
})(A.Point || (A.Point = {}));
60-
var Point = A.Point;
60+
})(Point = A.Point || (A.Point = {}));
6161
})(A || (A = {}));

tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ var A;
4646
return Point;
4747
})();
4848
A.Point = Point;
49+
var Point;
4950
(function (Point) {
5051
Point.Origin = ""; //expected duplicate identifier error
51-
})(A.Point || (A.Point = {}));
52-
var Point = A.Point;
52+
})(Point = A.Point || (A.Point = {}));
5353
})(A || (A = {}));

tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ var A;
4646
return Point;
4747
})();
4848
A.Point = Point;
49+
var Point;
4950
(function (Point) {
5051
var Origin = ""; // not an error since not exported
51-
})(A.Point || (A.Point = {}));
52-
var Point = A.Point;
52+
})(Point = A.Point || (A.Point = {}));
5353
})(A || (A = {}));

tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRoot.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var a: { id: string };
4343
//// [class.js]
4444
var X;
4545
(function (X) {
46+
var Y;
4647
(function (Y) {
4748
var Point = (function () {
4849
function Point(x, y) {
@@ -52,19 +53,18 @@ var X;
5253
return Point;
5354
})();
5455
Y.Point = Point;
55-
})(X.Y || (X.Y = {}));
56-
var Y = X.Y;
56+
})(Y = X.Y || (X.Y = {}));
5757
})(X || (X = {}));
5858
//// [module.js]
5959
var X;
6060
(function (X) {
61+
var Y;
6162
(function (Y) {
63+
var Point;
6264
(function (Point) {
6365
Point.Origin = new Point(0, 0);
64-
})(Y.Point || (Y.Point = {}));
65-
var Point = Y.Point;
66-
})(X.Y || (X.Y = {}));
67-
var Y = X.Y;
66+
})(Point = Y.Point || (Y.Point = {}));
67+
})(Y = X.Y || (X.Y = {}));
6868
})(X || (X = {}));
6969
//// [test.js]
7070
//var cl: { x: number; y: number; }

tests/baselines/reference/ExportModuleWithAccessibleTypesOnItsExportedMembers.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var A;
3131
return Point;
3232
})();
3333
A.Point = Point;
34+
var B;
3435
(function (B) {
3536
B.Origin = new Point(0, 0);
3637
var Line = (function () {
@@ -42,6 +43,5 @@ var A;
4243
return Line;
4344
})();
4445
B.Line = Line;
45-
})(A.B || (A.B = {}));
46-
var B = A.B;
46+
})(B = A.B || (A.B = {}));
4747
})(A || (A = {}));

tests/baselines/reference/FunctionAndModuleWithSameNameAndCommonRoot.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ var A;
5454
//// [module.js]
5555
var A;
5656
(function (A) {
57+
var Point;
5758
(function (Point) {
5859
Point.Origin = { x: 0, y: 0 };
59-
})(A.Point || (A.Point = {}));
60-
var Point = A.Point;
60+
})(Point = A.Point || (A.Point = {}));
6161
})(A || (A = {}));
6262
//// [test.js]
6363
var fn;
@@ -72,10 +72,10 @@ var B;
7272
return { x: 0, y: 0 };
7373
}
7474
B.Point = Point;
75+
var Point;
7576
(function (Point) {
7677
Point.Origin = { x: 0, y: 0 };
77-
})(B.Point || (B.Point = {}));
78-
var Point = B.Point;
78+
})(Point = B.Point || (B.Point = {}));
7979
})(B || (B = {}));
8080
var fn;
8181
var fn = B.Point; // not expected to be an error. bug 840000: [corelang] Function of fundule not assignalbe as expected

tests/baselines/reference/FunctionAndModuleWithSameNameAndDifferentCommonRoot.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ var A;
3333
//// [module.js]
3434
var B;
3535
(function (B) {
36+
var Point;
3637
(function (Point) {
3738
Point.Origin = { x: 0, y: 0 };
38-
})(B.Point || (B.Point = {}));
39-
var Point = B.Point;
39+
})(Point = B.Point || (B.Point = {}));
4040
})(B || (B = {}));
4141
//// [test.js]
4242
var fn;

0 commit comments

Comments
 (0)