Skip to content

Commit d99eb16

Browse files
committed
Merge branch 'master' into constructor-functions-as-classes
2 parents 537bd1b + 489abca commit d99eb16

File tree

93 files changed

+1818
-389
lines changed

Some content is hidden

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

93 files changed

+1818
-389
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "typescript",
33
"author": "Microsoft Corp.",
44
"homepage": "https://www.typescriptlang.org/",
5-
"version": "3.6.0",
5+
"version": "3.7.0",
66
"license": "Apache-2.0",
77
"description": "TypeScript is a language for application scale JavaScript development",
88
"keywords": [

scripts/build/options.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = minimist(process.argv.slice(2), {
1515
"r": "reporter",
1616
"c": "colors", "color": "colors",
1717
"skip-percent": "skipPercent",
18+
"skippercent": "skipPercent",
1819
"w": "workers",
1920
"f": "fix"
2021
},

src/compiler/binder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ namespace ts {
782782
function isNarrowableReference(expr: Expression): boolean {
783783
return expr.kind === SyntaxKind.Identifier || expr.kind === SyntaxKind.ThisKeyword || expr.kind === SyntaxKind.SuperKeyword ||
784784
(isPropertyAccessExpression(expr) || isNonNullExpression(expr) || isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) ||
785-
isElementAccessExpression(expr) && expr.argumentExpression &&
785+
isElementAccessExpression(expr) &&
786786
(isStringLiteral(expr.argumentExpression) || isNumericLiteral(expr.argumentExpression)) &&
787787
isNarrowableReference(expr.expression);
788788
}

src/compiler/checker.ts

Lines changed: 96 additions & 89 deletions
Large diffs are not rendered by default.

src/compiler/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace ts {
22
// WARNING: The script `configureNightly.ts` uses a regexp to parse out these values.
33
// If changing the text in this section, be sure to test `configureNightly` too.
4-
export const versionMajorMinor = "3.6";
4+
export const versionMajorMinor = "3.7";
55
/** The version of the TypeScript compiler release */
66
export const version = `${versionMajorMinor}.0-dev`;
77
}

src/compiler/diagnosticMessages.json

Lines 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

src/compiler/parser.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5492,10 +5492,22 @@ namespace ts {
54925492
}
54935493

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

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

src/compiler/program.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ namespace ts {
11451145
// If we change our policy of rechecking failed lookups on each program create,
11461146
// we should adjust the value returned here.
11471147
function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName: string): boolean {
1148-
const resolutionToFile = getResolvedModule(oldSourceFile!, moduleName);
1148+
const resolutionToFile = getResolvedModule(oldSourceFile, moduleName);
11491149
const resolvedFile = resolutionToFile && oldProgram!.getSourceFile(resolutionToFile.resolvedFileName);
11501150
if (resolutionToFile && resolvedFile) {
11511151
// In the old program, we resolved to an ambient module that was in the same
@@ -1833,6 +1833,7 @@ namespace ts {
18331833

18341834
switch (parent.kind) {
18351835
case SyntaxKind.ClassDeclaration:
1836+
case SyntaxKind.ClassExpression:
18361837
case SyntaxKind.MethodDeclaration:
18371838
case SyntaxKind.MethodSignature:
18381839
case SyntaxKind.Constructor:
@@ -1842,7 +1843,7 @@ namespace ts {
18421843
case SyntaxKind.FunctionDeclaration:
18431844
case SyntaxKind.ArrowFunction:
18441845
// Check type parameters
1845-
if (nodes === (<ClassDeclaration | FunctionLikeDeclaration>parent).typeParameters) {
1846+
if (nodes === (<ClassLikeDeclaration | FunctionLikeDeclaration>parent).typeParameters) {
18461847
diagnostics.push(createDiagnosticForNodeArray(nodes, Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file));
18471848
return;
18481849
}

src/compiler/scanner.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ namespace ts {
878878

879879
setText(text, start, length);
880880

881-
return {
881+
const scanner: Scanner = {
882882
getStartPos: () => startPos,
883883
getTextPos: () => pos,
884884
getToken: () => token,
@@ -914,6 +914,17 @@ namespace ts {
914914
scanRange,
915915
};
916916

917+
if (Debug.isDebugging) {
918+
Object.defineProperty(scanner, "__debugShowCurrentPositionInText", {
919+
get: () => {
920+
const text = scanner.getText();
921+
return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos());
922+
},
923+
});
924+
}
925+
926+
return scanner;
927+
917928
function error(message: DiagnosticMessage): void;
918929
function error(message: DiagnosticMessage, errPos: number, length: number): void;
919930
function error(message: DiagnosticMessage, errPos: number = pos, length?: number): void {
@@ -1472,7 +1483,7 @@ namespace ts {
14721483

14731484
function scan(): SyntaxKind {
14741485
startPos = pos;
1475-
tokenFlags = 0;
1486+
tokenFlags = TokenFlags.None;
14761487
let asteriskSeen = false;
14771488
while (true) {
14781489
tokenPos = pos;
@@ -2104,7 +2115,7 @@ namespace ts {
21042115

21052116
function scanJsDocToken(): JSDocSyntaxKind {
21062117
startPos = tokenPos = pos;
2107-
tokenFlags = 0;
2118+
tokenFlags = TokenFlags.None;
21082119
if (pos >= end) {
21092120
return token = SyntaxKind.EndOfFileToken;
21102121
}
@@ -2265,7 +2276,7 @@ namespace ts {
22652276
tokenPos = textPos;
22662277
token = SyntaxKind.Unknown;
22672278
tokenValue = undefined!;
2268-
tokenFlags = 0;
2279+
tokenFlags = TokenFlags.None;
22692280
}
22702281

22712282
function setInJSDocType(inType: boolean) {

src/compiler/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3345,7 +3345,7 @@ namespace ts {
33453345
* This should be called in a loop climbing parents of the symbol, so we'll get `N`.
33463346
*/
33473347
/* @internal */ getAccessibleSymbolChain(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, useOnlyExternalAliasing: boolean): Symbol[] | undefined;
3348-
/* @internal */ getTypePredicateOfSignature(signature: Signature): TypePredicate;
3348+
/* @internal */ getTypePredicateOfSignature(signature: Signature): TypePredicate | undefined;
33493349
/**
33503350
* An external module with an 'export =' declaration resolves to the target of the 'export =' declaration,
33513351
* and an external module with no 'export =' declaration resolves to the module itself.
@@ -4502,8 +4502,10 @@ namespace ts {
45024502
LiteralKeyof = 1 << 5, // Inference made from a string literal to a keyof T
45034503
NoConstraints = 1 << 6, // Don't infer from constraints of instantiable types
45044504
AlwaysStrict = 1 << 7, // Always use strict rules for contravariant inferences
4505+
MaxValue = 1 << 8, // Seed for inference priority tracking
45054506

45064507
PriorityImpliesCombination = ReturnType | MappedTypeConstraint | LiteralKeyof, // These priorities imply that the resulting type should be a combination of all candidates
4508+
Circularity = -1, // Inference circularity (value less than all other priorities)
45074509
}
45084510

45094511
/* @internal */

0 commit comments

Comments
 (0)