Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b6d981a

Browse filesBrowse files
committed
Merge branch 'master' of https://github.com/Microsoft/TypeScript into feature/eslint
2 parents d532bf6 + a53e4a1 commit b6d981a
Copy full SHA for b6d981a

44 files changed

+1,193-113Lines changed: 1193 additions & 113 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/compiler/binder.ts‎

Copy file name to clipboardExpand all lines: src/compiler/binder.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ namespace ts {
778778
function isNarrowableReference(expr: Expression): boolean {
779779
return expr.kind === SyntaxKind.Identifier || expr.kind === SyntaxKind.ThisKeyword || expr.kind === SyntaxKind.SuperKeyword ||
780780
(isPropertyAccessExpression(expr) || isNonNullExpression(expr) || isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) ||
781-
isElementAccessExpression(expr) && expr.argumentExpression &&
781+
isElementAccessExpression(expr) &&
782782
(isStringLiteral(expr.argumentExpression) || isNumericLiteral(expr.argumentExpression)) &&
783783
isNarrowableReference(expr.expression);
784784
}
Collapse file

‎src/compiler/checker.ts‎

Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+31-44Lines changed: 31 additions & 44 deletions
Large diffs are not rendered by default.
Collapse file

‎src/compiler/diagnosticMessages.json‎

Copy file name to clipboardExpand all lines: src/compiler/diagnosticMessages.json
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,6 @@
459459
"category": "Error",
460460
"code": 1149
461461
},
462-
"'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead.": {
463-
"category": "Error",
464-
"code": 1150
465-
},
466462
"'const' declarations must be initialized.": {
467463
"category": "Error",
468464
"code": 1155
Collapse file

‎src/compiler/parser.ts‎

Copy file name to clipboardExpand all lines: src/compiler/parser.ts
+22-1Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5490,10 +5490,22 @@ namespace ts {
54905490
}
54915491

54925492
function parseDeclaration(): Statement {
5493+
const modifiers = lookAhead(() => (parseDecorators(), parseModifiers()));
5494+
// `parseListElement` attempted to get the reused node at this position,
5495+
// but the ambient context flag was not yet set, so the node appeared
5496+
// not reusable in that context.
5497+
const isAmbient = some(modifiers, isDeclareModifier);
5498+
if (isAmbient) {
5499+
const node = tryReuseAmbientDeclaration();
5500+
if (node) {
5501+
return node;
5502+
}
5503+
}
5504+
54935505
const node = <Statement>createNodeWithJSDoc(SyntaxKind.Unknown);
54945506
node.decorators = parseDecorators();
54955507
node.modifiers = parseModifiers();
5496-
if (some(node.modifiers, isDeclareModifier)) {
5508+
if (isAmbient) {
54975509
for (const m of node.modifiers!) {
54985510
m.flags |= NodeFlags.Ambient;
54995511
}
@@ -5504,6 +5516,15 @@ namespace ts {
55045516
}
55055517
}
55065518

5519+
function tryReuseAmbientDeclaration(): Statement | undefined {
5520+
return doInsideOfContext(NodeFlags.Ambient, () => {
5521+
const node = currentNode(parsingContext);
5522+
if (node) {
5523+
return consumeNode(node) as Statement;
5524+
}
5525+
});
5526+
}
5527+
55075528
function parseDeclarationWorker(node: Statement): Statement {
55085529
switch (token()) {
55095530
case SyntaxKind.VarKeyword:
Collapse file

‎src/compiler/program.ts‎

Copy file name to clipboardExpand all lines: src/compiler/program.ts
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ namespace ts {
11421142
// If we change our policy of rechecking failed lookups on each program create,
11431143
// we should adjust the value returned here.
11441144
function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName: string): boolean {
1145-
const resolutionToFile = getResolvedModule(oldSourceFile!, moduleName);
1145+
const resolutionToFile = getResolvedModule(oldSourceFile, moduleName);
11461146
const resolvedFile = resolutionToFile && oldProgram!.getSourceFile(resolutionToFile.resolvedFileName);
11471147
if (resolutionToFile && resolvedFile) {
11481148
// In the old program, we resolved to an ambient module that was in the same
@@ -1831,6 +1831,7 @@ namespace ts {
18311831

18321832
switch (parent.kind) {
18331833
case SyntaxKind.ClassDeclaration:
1834+
case SyntaxKind.ClassExpression:
18341835
case SyntaxKind.MethodDeclaration:
18351836
case SyntaxKind.MethodSignature:
18361837
case SyntaxKind.Constructor:
@@ -1840,7 +1841,7 @@ namespace ts {
18401841
case SyntaxKind.FunctionDeclaration:
18411842
case SyntaxKind.ArrowFunction:
18421843
// Check type parameters
1843-
if (nodes === (<ClassDeclaration | FunctionLikeDeclaration>parent).typeParameters) {
1844+
if (nodes === (<ClassLikeDeclaration | FunctionLikeDeclaration>parent).typeParameters) {
18441845
diagnostics.push(createDiagnosticForNodeArray(nodes, Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file));
18451846
return;
18461847
}
Collapse file

‎src/compiler/scanner.ts‎

Copy file name to clipboardExpand all lines: src/compiler/scanner.ts
+12-1Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ namespace ts {
879879

880880
setText(text, start, length);
881881

882-
return {
882+
const scanner: Scanner = {
883883
getStartPos: () => startPos,
884884
getTextPos: () => pos,
885885
getToken: () => token,
@@ -915,6 +915,17 @@ namespace ts {
915915
scanRange,
916916
};
917917

918+
if (Debug.isDebugging) {
919+
Object.defineProperty(scanner, "__debugShowCurrentPositionInText", {
920+
get: () => {
921+
const text = scanner.getText();
922+
return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos());
923+
},
924+
});
925+
}
926+
927+
return scanner;
928+
918929
function error(message: DiagnosticMessage): void;
919930
function error(message: DiagnosticMessage, errPos: number, length: number): void;
920931
function error(message: DiagnosticMessage, errPos: number = pos, length?: number): void {
Collapse file

‎src/compiler/types.ts‎

Copy file name to clipboardExpand all lines: src/compiler/types.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3346,7 +3346,7 @@ namespace ts {
33463346
* This should be called in a loop climbing parents of the symbol, so we'll get `N`.
33473347
*/
33483348
/* @internal */ getAccessibleSymbolChain(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, useOnlyExternalAliasing: boolean): Symbol[] | undefined;
3349-
/* @internal */ getTypePredicateOfSignature(signature: Signature): TypePredicate;
3349+
/* @internal */ getTypePredicateOfSignature(signature: Signature): TypePredicate | undefined;
33503350
/**
33513351
* An external module with an 'export =' declaration resolves to the target of the 'export =' declaration,
33523352
* and an external module with no 'export =' declaration resolves to the module itself.
Collapse file

‎src/compiler/utilities.ts‎

Copy file name to clipboardExpand all lines: src/compiler/utilities.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ namespace ts {
220220
return node.end - node.pos;
221221
}
222222

223-
export function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModuleFull | undefined {
223+
export function getResolvedModule(sourceFile: SourceFile | undefined, moduleNameText: string): ResolvedModuleFull | undefined {
224224
return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText);
225225
}
226226

Collapse file

‎src/lib/es2019.array.d.ts‎

Copy file name to clipboardExpand all lines: src/lib/es2019.array.d.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ interface ReadonlyArray<T> {
110110
* @param depth The maximum recursion depth
111111
*/
112112
flat<U>(depth?: number): any[];
113-
}
113+
}
114114

115115
interface Array<T> {
116116

Collapse file

‎src/lib/es5.d.ts‎

Copy file name to clipboardExpand all lines: src/lib/es5.d.ts
+20-29Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ interface ReadonlyArray<T> {
10941094
/**
10951095
* Returns a section of an array.
10961096
* @param start The beginning of the specified portion of the array.
1097-
* @param end The end of the specified portion of the array.
1097+
* @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'.
10981098
*/
10991099
slice(start?: number, end?: number): T[];
11001100
/**
@@ -1230,7 +1230,7 @@ interface Array<T> {
12301230
/**
12311231
* Returns a section of an array.
12321232
* @param start The beginning of the specified portion of the array.
1233-
* @param end The end of the specified portion of the array.
1233+
* @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'.
12341234
*/
12351235
slice(start?: number, end?: number): T[];
12361236
/**
@@ -1860,7 +1860,7 @@ interface Int8Array {
18601860
/**
18611861
* Returns a section of an array.
18621862
* @param start The beginning of the specified portion of the array.
1863-
* @param end The end of the specified portion of the array.
1863+
* @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'.
18641864
*/
18651865
slice(start?: number, end?: number): Int8Array;
18661866

@@ -1887,7 +1887,7 @@ interface Int8Array {
18871887
* @param begin The index of the beginning of the array.
18881888
* @param end The index of the end of the array.
18891889
*/
1890-
subarray(begin: number, end?: number): Int8Array;
1890+
subarray(begin?: number, end?: number): Int8Array;
18911891

18921892
/**
18931893
* Converts a number to a string by using the current locale.
@@ -2135,7 +2135,7 @@ interface Uint8Array {
21352135
/**
21362136
* Returns a section of an array.
21372137
* @param start The beginning of the specified portion of the array.
2138-
* @param end The end of the specified portion of the array.
2138+
* @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'.
21392139
*/
21402140
slice(start?: number, end?: number): Uint8Array;
21412141

@@ -2162,7 +2162,7 @@ interface Uint8Array {
21622162
* @param begin The index of the beginning of the array.
21632163
* @param end The index of the end of the array.
21642164
*/
2165-
subarray(begin: number, end?: number): Uint8Array;
2165+
subarray(begin?: number, end?: number): Uint8Array;
21662166

21672167
/**
21682168
* Converts a number to a string by using the current locale.
@@ -2410,7 +2410,7 @@ interface Uint8ClampedArray {
24102410
/**
24112411
* Returns a section of an array.
24122412
* @param start The beginning of the specified portion of the array.
2413-
* @param end The end of the specified portion of the array.
2413+
* @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'.
24142414
*/
24152415
slice(start?: number, end?: number): Uint8ClampedArray;
24162416

@@ -2437,7 +2437,7 @@ interface Uint8ClampedArray {
24372437
* @param begin The index of the beginning of the array.
24382438
* @param end The index of the end of the array.
24392439
*/
2440-
subarray(begin: number, end?: number): Uint8ClampedArray;
2440+
subarray(begin?: number, end?: number): Uint8ClampedArray;
24412441

24422442
/**
24432443
* Converts a number to a string by using the current locale.
@@ -2683,7 +2683,7 @@ interface Int16Array {
26832683
/**
26842684
* Returns a section of an array.
26852685
* @param start The beginning of the specified portion of the array.
2686-
* @param end The end of the specified portion of the array.
2686+
* @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'.
26872687
*/
26882688
slice(start?: number, end?: number): Int16Array;
26892689

@@ -2710,7 +2710,7 @@ interface Int16Array {
27102710
* @param begin The index of the beginning of the array.
27112711
* @param end The index of the end of the array.
27122712
*/
2713-
subarray(begin: number, end?: number): Int16Array;
2713+
subarray(begin?: number, end?: number): Int16Array;
27142714

27152715
/**
27162716
* Converts a number to a string by using the current locale.
@@ -2959,7 +2959,7 @@ interface Uint16Array {
29592959
/**
29602960
* Returns a section of an array.
29612961
* @param start The beginning of the specified portion of the array.
2962-
* @param end The end of the specified portion of the array.
2962+
* @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'.
29632963
*/
29642964
slice(start?: number, end?: number): Uint16Array;
29652965

@@ -2986,7 +2986,7 @@ interface Uint16Array {
29862986
* @param begin The index of the beginning of the array.
29872987
* @param end The index of the end of the array.
29882988
*/
2989-
subarray(begin: number, end?: number): Uint16Array;
2989+
subarray(begin?: number, end?: number): Uint16Array;
29902990

29912991
/**
29922992
* Converts a number to a string by using the current locale.
@@ -3234,7 +3234,7 @@ interface Int32Array {
32343234
/**
32353235
* Returns a section of an array.
32363236
* @param start The beginning of the specified portion of the array.
3237-
* @param end The end of the specified portion of the array.
3237+
* @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'.
32383238
*/
32393239
slice(start?: number, end?: number): Int32Array;
32403240

@@ -3261,7 +3261,7 @@ interface Int32Array {
32613261
* @param begin The index of the beginning of the array.
32623262
* @param end The index of the end of the array.
32633263
*/
3264-
subarray(begin: number, end?: number): Int32Array;
3264+
subarray(begin?: number, end?: number): Int32Array;
32653265

32663266
/**
32673267
* Converts a number to a string by using the current locale.
@@ -3508,7 +3508,7 @@ interface Uint32Array {
35083508
/**
35093509
* Returns a section of an array.
35103510
* @param start The beginning of the specified portion of the array.
3511-
* @param end The end of the specified portion of the array.
3511+
* @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'.
35123512
*/
35133513
slice(start?: number, end?: number): Uint32Array;
35143514

@@ -3535,7 +3535,7 @@ interface Uint32Array {
35353535
* @param begin The index of the beginning of the array.
35363536
* @param end The index of the end of the array.
35373537
*/
3538-
subarray(begin: number, end?: number): Uint32Array;
3538+
subarray(begin?: number, end?: number): Uint32Array;
35393539

35403540
/**
35413541
* Converts a number to a string by using the current locale.
@@ -3783,7 +3783,7 @@ interface Float32Array {
37833783
/**
37843784
* Returns a section of an array.
37853785
* @param start The beginning of the specified portion of the array.
3786-
* @param end The end of the specified portion of the array.
3786+
* @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'.
37873787
*/
37883788
slice(start?: number, end?: number): Float32Array;
37893789

@@ -3810,7 +3810,7 @@ interface Float32Array {
38103810
* @param begin The index of the beginning of the array.
38113811
* @param end The index of the end of the array.
38123812
*/
3813-
subarray(begin: number, end?: number): Float32Array;
3813+
subarray(begin?: number, end?: number): Float32Array;
38143814

38153815
/**
38163816
* Converts a number to a string by using the current locale.
@@ -4059,7 +4059,7 @@ interface Float64Array {
40594059
/**
40604060
* Returns a section of an array.
40614061
* @param start The beginning of the specified portion of the array.
4062-
* @param end The end of the specified portion of the array.
4062+
* @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'.
40634063
*/
40644064
slice(start?: number, end?: number): Float64Array;
40654065

@@ -4081,21 +4081,12 @@ interface Float64Array {
40814081
sort(compareFn?: (a: number, b: number) => number): this;
40824082

40834083
/**
4084-
* Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements
40854084
* at begin, inclusive, up to end, exclusive.
40864085
* @param begin The index of the beginning of the array.
40874086
* @param end The index of the end of the array.
40884087
*/
4089-
subarray(begin: number, end?: number): Float64Array;
4088+
subarray(begin?: number, end?: number): Float64Array;
40904089

4091-
/**
4092-
* Converts a number to a string by using the current locale.
4093-
*/
4094-
toLocaleString(): string;
4095-
4096-
/**
4097-
* Returns a string representation of an array.
4098-
*/
40994090
toString(): string;
41004091

41014092
[index: number]: number;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.