Skip to content

Commit 45f0d7c

Browse files
committed
Merge branch 'master' into metadataDecoratorOption
# Conflicts: # src/compiler/diagnosticMessages.json
2 parents 116c099 + 3b06ef1 commit 45f0d7c

File tree

188 files changed

+3303
-1165
lines changed

Some content is hidden

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

188 files changed

+3303
-1165
lines changed

package-lock.json

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/compiler/checker.ts

Lines changed: 118 additions & 70 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,7 @@ namespace ts {
875875
{
876876
name: "metadataDecorator",
877877
type: "string",
878+
affectsEmit: true,
878879
category: Diagnostics.Advanced_Options,
879880
description: Diagnostics.Specify_the_name_of_the_metadata_decorator_function_to_use_when_emitDecoratorMetadata_is_set
880881
},

src/compiler/diagnosticMessages.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"category": "Error",
1616
"code": 1006
1717
},
18-
"The parser expected to find a '}' to match the '{' token here.": {
18+
"The parser expected to find a '{1}' to match the '{0}' token here.": {
1919
"category": "Error",
2020
"code": 1007
2121
},
@@ -3181,7 +3181,7 @@
31813181
"category": "Error",
31823182
"code": 2773
31833183
},
3184-
"This condition will always return true since the function is always defined. Did you mean to call it instead?": {
3184+
"This condition will always return true since this function appears to always be defined. Did you mean to call it instead?": {
31853185
"category": "Error",
31863186
"code": 2774
31873187
},
@@ -3289,7 +3289,7 @@
32893289
"category": "Error",
32903290
"code": 2800
32913291
},
3292-
"This condition will always return true since the Promise is always truthy.": {
3292+
"This condition will always return true since this '{0}' appears to always be defined.": {
32933293
"category": "Error",
32943294
"code": 2801
32953295
},
@@ -3321,18 +3321,22 @@
33213321
"category": "Error",
33223322
"code": 2808
33233323
},
3324-
"Namespace '{0}' from module '{1}' has no exported member '{2}'.": {
3324+
"Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses.": {
33253325
"category": "Error",
33263326
"code": 2809
33273327
},
3328-
"'{0}' from module '{1}' has no exported member named '{2}'. Did you mean '{3}'?": {
3328+
"Namespace '{0}' from module '{1}' has no exported member '{2}'.": {
33293329
"category": "Error",
33303330
"code": 2810
33313331
},
3332-
"Cannot find namespace '{0}'. Did you mean '{1}?": {
3332+
"'{0}' from module '{1}' has no exported member named '{2}'. Did you mean '{3}'?": {
33333333
"category": "Error",
33343334
"code": 2811
33353335
},
3336+
"Cannot find namespace '{0}'. Did you mean '{1}?": {
3337+
"category": "Error",
3338+
"code": 2812
3339+
},
33363340

33373341
"Import declaration '{0}' is using private name '{1}'.": {
33383342
"category": "Error",

src/compiler/parser.ts

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ namespace ts {
551551
case SyntaxKind.JSDocPrivateTag:
552552
case SyntaxKind.JSDocProtectedTag:
553553
case SyntaxKind.JSDocReadonlyTag:
554+
case SyntaxKind.JSDocDeprecatedTag:
554555
return visitNode(cbNode, (node as JSDocTag).tagName)
555556
|| (typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray<JSDocText | JSDocLink> | undefined));
556557
case SyntaxKind.PartiallyEmittedExpression:
@@ -1335,24 +1336,27 @@ namespace ts {
13351336
return inContext(NodeFlags.AwaitContext);
13361337
}
13371338

1338-
function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): void {
1339-
parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
1339+
function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | undefined {
1340+
return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
13401341
}
13411342

1342-
function parseErrorAtPosition(start: number, length: number, message: DiagnosticMessage, arg0?: any): void {
1343+
function parseErrorAtPosition(start: number, length: number, message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | undefined {
13431344
// Don't report another error if it would just be at the same position as the last error.
13441345
const lastError = lastOrUndefined(parseDiagnostics);
1346+
let result: DiagnosticWithDetachedLocation | undefined;
13451347
if (!lastError || start !== lastError.start) {
1346-
parseDiagnostics.push(createDetachedDiagnostic(fileName, start, length, message, arg0));
1348+
result = createDetachedDiagnostic(fileName, start, length, message, arg0);
1349+
parseDiagnostics.push(result);
13471350
}
13481351

13491352
// Mark that we've encountered an error. We'll set an appropriate bit on the next
13501353
// node we finish so that it can't be reused incrementally.
13511354
parseErrorBeforeNextFinishedNode = true;
1355+
return result;
13521356
}
13531357

1354-
function parseErrorAt(start: number, end: number, message: DiagnosticMessage, arg0?: any): void {
1355-
parseErrorAtPosition(start, end - start, message, arg0);
1358+
function parseErrorAt(start: number, end: number, message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | undefined {
1359+
return parseErrorAtPosition(start, end - start, message, arg0);
13561360
}
13571361

13581362
function parseErrorAtRange(range: TextRange, message: DiagnosticMessage, arg0?: any): void {
@@ -1542,6 +1546,20 @@ namespace ts {
15421546
return false;
15431547
}
15441548

1549+
function parseExpectedMatchingBrackets(openKind: SyntaxKind, closeKind: SyntaxKind, openPosition: number) {
1550+
if (token() === closeKind) {
1551+
nextToken();
1552+
return;
1553+
}
1554+
const lastError = parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(closeKind));
1555+
if (lastError) {
1556+
addRelatedInfo(
1557+
lastError,
1558+
createDetachedDiagnostic(fileName, openPosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, tokenToString(openKind), tokenToString(closeKind))
1559+
);
1560+
}
1561+
}
1562+
15451563
function parseOptional(t: SyntaxKind): boolean {
15461564
if (token() === t) {
15471565
nextToken();
@@ -2092,8 +2110,7 @@ namespace ts {
20922110

20932111
while (!isListTerminator(kind)) {
20942112
if (isListElement(kind, /*inErrorRecovery*/ false)) {
2095-
const element = parseListElement(kind, parseElement);
2096-
list.push(element);
2113+
list.push(parseListElement(kind, parseElement));
20972114

20982115
continue;
20992116
}
@@ -5426,10 +5443,11 @@ namespace ts {
54265443

54275444
function parseArrayLiteralExpression(): ArrayLiteralExpression {
54285445
const pos = getNodePos();
5446+
const openBracketPosition = scanner.getTokenPos();
54295447
parseExpected(SyntaxKind.OpenBracketToken);
54305448
const multiLine = scanner.hasPrecedingLineBreak();
54315449
const elements = parseDelimitedList(ParsingContext.ArrayLiteralMembers, parseArgumentOrArrayLiteralElement);
5432-
parseExpected(SyntaxKind.CloseBracketToken);
5450+
parseExpectedMatchingBrackets(SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken, openBracketPosition);
54335451
return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos);
54345452
}
54355453

@@ -5498,15 +5516,7 @@ namespace ts {
54985516
parseExpected(SyntaxKind.OpenBraceToken);
54995517
const multiLine = scanner.hasPrecedingLineBreak();
55005518
const properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true);
5501-
if (!parseExpected(SyntaxKind.CloseBraceToken)) {
5502-
const lastError = lastOrUndefined(parseDiagnostics);
5503-
if (lastError && lastError.code === Diagnostics._0_expected.code) {
5504-
addRelatedInfo(
5505-
lastError,
5506-
createDetachedDiagnostic(fileName, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)
5507-
);
5508-
}
5509-
}
5519+
parseExpectedMatchingBrackets(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, openBracePosition);
55105520
return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos);
55115521
}
55125522

@@ -5591,16 +5601,14 @@ namespace ts {
55915601
if (parseExpected(SyntaxKind.OpenBraceToken, diagnosticMessage) || ignoreMissingOpenBrace) {
55925602
const multiLine = scanner.hasPrecedingLineBreak();
55935603
const statements = parseList(ParsingContext.BlockStatements, parseStatement);
5594-
if (!parseExpected(SyntaxKind.CloseBraceToken)) {
5595-
const lastError = lastOrUndefined(parseDiagnostics);
5596-
if (lastError && lastError.code === Diagnostics._0_expected.code) {
5597-
addRelatedInfo(
5598-
lastError,
5599-
createDetachedDiagnostic(fileName, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)
5600-
);
5601-
}
5604+
parseExpectedMatchingBrackets(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, openBracePosition);
5605+
const result = finishNode(factory.createBlock(statements, multiLine), pos);
5606+
if (token() === SyntaxKind.EqualsToken) {
5607+
parseErrorAtCurrentToken(Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses);
5608+
nextToken();
56025609
}
5603-
return finishNode(factory.createBlock(statements, multiLine), pos);
5610+
5611+
return result;
56045612
}
56055613
else {
56065614
const statements = createMissingList<Statement>();
@@ -5647,9 +5655,10 @@ namespace ts {
56475655
function parseIfStatement(): IfStatement {
56485656
const pos = getNodePos();
56495657
parseExpected(SyntaxKind.IfKeyword);
5658+
const openParenPosition = scanner.getTokenPos();
56505659
parseExpected(SyntaxKind.OpenParenToken);
56515660
const expression = allowInAnd(parseExpression);
5652-
parseExpected(SyntaxKind.CloseParenToken);
5661+
parseExpectedMatchingBrackets(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken, openParenPosition);
56535662
const thenStatement = parseStatement();
56545663
const elseStatement = parseOptional(SyntaxKind.ElseKeyword) ? parseStatement() : undefined;
56555664
return finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos);
@@ -5660,9 +5669,10 @@ namespace ts {
56605669
parseExpected(SyntaxKind.DoKeyword);
56615670
const statement = parseStatement();
56625671
parseExpected(SyntaxKind.WhileKeyword);
5672+
const openParenPosition = scanner.getTokenPos();
56635673
parseExpected(SyntaxKind.OpenParenToken);
56645674
const expression = allowInAnd(parseExpression);
5665-
parseExpected(SyntaxKind.CloseParenToken);
5675+
parseExpectedMatchingBrackets(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken, openParenPosition);
56665676

56675677
// From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html
56685678
// 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in
@@ -5675,9 +5685,10 @@ namespace ts {
56755685
function parseWhileStatement(): WhileStatement {
56765686
const pos = getNodePos();
56775687
parseExpected(SyntaxKind.WhileKeyword);
5688+
const openParenPosition = scanner.getTokenPos();
56785689
parseExpected(SyntaxKind.OpenParenToken);
56795690
const expression = allowInAnd(parseExpression);
5680-
parseExpected(SyntaxKind.CloseParenToken);
5691+
parseExpectedMatchingBrackets(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken, openParenPosition);
56815692
const statement = parseStatement();
56825693
return finishNode(factory.createWhileStatement(expression, statement), pos);
56835694
}
@@ -5749,9 +5760,10 @@ namespace ts {
57495760
function parseWithStatement(): WithStatement {
57505761
const pos = getNodePos();
57515762
parseExpected(SyntaxKind.WithKeyword);
5763+
const openParenPosition = scanner.getTokenPos();
57525764
parseExpected(SyntaxKind.OpenParenToken);
57535765
const expression = allowInAnd(parseExpression);
5754-
parseExpected(SyntaxKind.CloseParenToken);
5766+
parseExpectedMatchingBrackets(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken, openParenPosition);
57555767
const statement = doInsideOfContext(NodeFlags.InWithStatement, parseStatement);
57565768
return finishNode(factory.createWithStatement(expression, statement), pos);
57575769
}
@@ -7973,13 +7985,9 @@ namespace ts {
79737985
hasChildren = true;
79747986
if (child.kind === SyntaxKind.JSDocTypeTag) {
79757987
if (childTypeTag) {
7976-
parseErrorAtCurrentToken(Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
7977-
const lastError = lastOrUndefined(parseDiagnostics);
7988+
const lastError = parseErrorAtCurrentToken(Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
79787989
if (lastError) {
7979-
addRelatedInfo(
7980-
lastError,
7981-
createDetachedDiagnostic(fileName, 0, 0, Diagnostics.The_tag_was_first_specified_here)
7982-
);
7990+
addRelatedInfo(lastError, createDetachedDiagnostic(fileName, 0, 0, Diagnostics.The_tag_was_first_specified_here));
79837991
}
79847992
break;
79857993
}
@@ -8011,7 +8019,7 @@ namespace ts {
80118019
}
80128020

80138021
const typedefTag = factory.createJSDocTypedefTag(tagName, typeExpression, fullName, comment);
8014-
return finishNode(typedefTag, start);
8022+
return finishNode(typedefTag, start, end);
80158023
}
80168024

80178025
function parseJSDocTypeNameWithNamespace(nested?: boolean) {

src/compiler/tsbuildPublic.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,11 @@ namespace ts {
17171717
continue;
17181718
}
17191719
const outputs = getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames());
1720+
if (!outputs.length) continue;
1721+
const inputFileNames = new Set(parsed.fileNames.map(f => toPath(state, f)));
17201722
for (const output of outputs) {
1723+
// If output name is same as input file name, do not delete and ignore the error
1724+
if (inputFileNames.has(toPath(state, output))) continue;
17211725
if (host.fileExists(output)) {
17221726
if (filesToDelete) {
17231727
filesToDelete.push(output);

src/compiler/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4353,7 +4353,6 @@ namespace ts {
43534353
InObjectTypeLiteral = 1 << 22,
43544354
InTypeAlias = 1 << 23, // Writing type in type alias declaration
43554355
InInitialEntityName = 1 << 24, // Set when writing the LHS of an entity name or entity name expression
4356-
InReverseMappedType = 1 << 25,
43574356
}
43584357

43594358
// Ensure the shared flags between this and `NodeBuilderFlags` stay in alignment

src/harness/client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ namespace ts.server {
306306
fileName: entry.file,
307307
textSpan: this.decodeSpan(entry),
308308
kind: ScriptElementKind.unknown,
309-
name: ""
309+
name: "",
310+
unverified: entry.unverified,
310311
})),
311312
textSpan: this.decodeSpan(body.textSpan, request.arguments.file)
312313
};

src/harness/compilerImpl.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ namespace compiler {
135135
}
136136
}
137137
}
138-
139-
this.diagnostics = diagnostics;
140138
}
141139

142140
public get vfs(): vfs.FileSystem {

0 commit comments

Comments
 (0)