Skip to content

Commit

Permalink
Merge branch 'master' into metadataDecoratorOption
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/compiler/diagnosticMessages.json
  • Loading branch information
rbuckton committed Apr 6, 2021
2 parents 116c099 + 3b06ef1 commit 2090c0f
Show file tree
Hide file tree
Showing 188 changed files with 3,305 additions and 1,167 deletions.
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

192 changes: 120 additions & 72 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ namespace ts {
{
name: "metadataDecorator",
type: "string",
affectsEmit: true,
category: Diagnostics.Advanced_Options,
description: Diagnostics.Specify_the_name_of_the_metadata_decorator_function_to_use_when_emitDecoratorMetadata_is_set
},
Expand Down
16 changes: 10 additions & 6 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"category": "Error",
"code": 1006
},
"The parser expected to find a '}' to match the '{' token here.": {
"The parser expected to find a '{1}' to match the '{0}' token here.": {
"category": "Error",
"code": 1007
},
Expand Down Expand Up @@ -3181,7 +3181,7 @@
"category": "Error",
"code": 2773
},
"This condition will always return true since the function is always defined. Did you mean to call it instead?": {
"This condition will always return true since this function appears to always be defined. Did you mean to call it instead?": {
"category": "Error",
"code": 2774
},
Expand Down Expand Up @@ -3289,7 +3289,7 @@
"category": "Error",
"code": 2800
},
"This condition will always return true since the Promise is always truthy.": {
"This condition will always return true since this '{0}' appears to always be defined.": {
"category": "Error",
"code": 2801
},
Expand Down Expand Up @@ -3321,18 +3321,22 @@
"category": "Error",
"code": 2808
},
"Namespace '{0}' from module '{1}' has no exported member '{2}'.": {
"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.": {
"category": "Error",
"code": 2809
},
"'{0}' from module '{1}' has no exported member named '{2}'. Did you mean '{3}'?": {
"Namespace '{0}' from module '{1}' has no exported member '{2}'.": {
"category": "Error",
"code": 2810
},
"Cannot find namespace '{0}'. Did you mean '{1}?": {
"'{0}' from module '{1}' has no exported member named '{2}'. Did you mean '{3}'?": {
"category": "Error",
"code": 2811
},
"Cannot find namespace '{0}'. Did you mean '{1}?": {
"category": "Error",
"code": 2812
},

"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
Expand Down
84 changes: 46 additions & 38 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ namespace ts {
case SyntaxKind.JSDocPrivateTag:
case SyntaxKind.JSDocProtectedTag:
case SyntaxKind.JSDocReadonlyTag:
case SyntaxKind.JSDocDeprecatedTag:
return visitNode(cbNode, (node as JSDocTag).tagName)
|| (typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray<JSDocText | JSDocLink> | undefined));
case SyntaxKind.PartiallyEmittedExpression:
Expand Down Expand Up @@ -1335,24 +1336,27 @@ namespace ts {
return inContext(NodeFlags.AwaitContext);
}

function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): void {
parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | undefined {
return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
}

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

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

function parseErrorAt(start: number, end: number, message: DiagnosticMessage, arg0?: any): void {
parseErrorAtPosition(start, end - start, message, arg0);
function parseErrorAt(start: number, end: number, message: DiagnosticMessage, arg0?: any): DiagnosticWithDetachedLocation | undefined {
return parseErrorAtPosition(start, end - start, message, arg0);
}

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

function parseExpectedMatchingBrackets(openKind: SyntaxKind, closeKind: SyntaxKind, openPosition: number) {
if (token() === closeKind) {
nextToken();
return;
}
const lastError = parseErrorAtCurrentToken(Diagnostics._0_expected, tokenToString(closeKind));
if (lastError) {
addRelatedInfo(
lastError,
createDetachedDiagnostic(fileName, openPosition, 1, Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, tokenToString(openKind), tokenToString(closeKind))
);
}
}

function parseOptional(t: SyntaxKind): boolean {
if (token() === t) {
nextToken();
Expand Down Expand Up @@ -2092,8 +2110,7 @@ namespace ts {

while (!isListTerminator(kind)) {
if (isListElement(kind, /*inErrorRecovery*/ false)) {
const element = parseListElement(kind, parseElement);
list.push(element);
list.push(parseListElement(kind, parseElement));

continue;
}
Expand Down Expand Up @@ -5426,10 +5443,11 @@ namespace ts {

function parseArrayLiteralExpression(): ArrayLiteralExpression {
const pos = getNodePos();
const openBracketPosition = scanner.getTokenPos();
parseExpected(SyntaxKind.OpenBracketToken);
const multiLine = scanner.hasPrecedingLineBreak();
const elements = parseDelimitedList(ParsingContext.ArrayLiteralMembers, parseArgumentOrArrayLiteralElement);
parseExpected(SyntaxKind.CloseBracketToken);
parseExpectedMatchingBrackets(SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken, openBracketPosition);
return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos);
}

Expand Down Expand Up @@ -5498,15 +5516,7 @@ namespace ts {
parseExpected(SyntaxKind.OpenBraceToken);
const multiLine = scanner.hasPrecedingLineBreak();
const properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true);
if (!parseExpected(SyntaxKind.CloseBraceToken)) {
const lastError = lastOrUndefined(parseDiagnostics);
if (lastError && lastError.code === Diagnostics._0_expected.code) {
addRelatedInfo(
lastError,
createDetachedDiagnostic(fileName, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)
);
}
}
parseExpectedMatchingBrackets(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, openBracePosition);
return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos);
}

Expand Down Expand Up @@ -5591,16 +5601,14 @@ namespace ts {
if (parseExpected(SyntaxKind.OpenBraceToken, diagnosticMessage) || ignoreMissingOpenBrace) {
const multiLine = scanner.hasPrecedingLineBreak();
const statements = parseList(ParsingContext.BlockStatements, parseStatement);
if (!parseExpected(SyntaxKind.CloseBraceToken)) {
const lastError = lastOrUndefined(parseDiagnostics);
if (lastError && lastError.code === Diagnostics._0_expected.code) {
addRelatedInfo(
lastError,
createDetachedDiagnostic(fileName, openBracePosition, 1, Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)
);
}
parseExpectedMatchingBrackets(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken, openBracePosition);
const result = finishNode(factory.createBlock(statements, multiLine), pos);
if (token() === SyntaxKind.EqualsToken) {
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);
nextToken();
}
return finishNode(factory.createBlock(statements, multiLine), pos);

return result;
}
else {
const statements = createMissingList<Statement>();
Expand Down Expand Up @@ -5647,9 +5655,10 @@ namespace ts {
function parseIfStatement(): IfStatement {
const pos = getNodePos();
parseExpected(SyntaxKind.IfKeyword);
const openParenPosition = scanner.getTokenPos();
parseExpected(SyntaxKind.OpenParenToken);
const expression = allowInAnd(parseExpression);
parseExpected(SyntaxKind.CloseParenToken);
parseExpectedMatchingBrackets(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken, openParenPosition);
const thenStatement = parseStatement();
const elseStatement = parseOptional(SyntaxKind.ElseKeyword) ? parseStatement() : undefined;
return finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos);
Expand All @@ -5660,9 +5669,10 @@ namespace ts {
parseExpected(SyntaxKind.DoKeyword);
const statement = parseStatement();
parseExpected(SyntaxKind.WhileKeyword);
const openParenPosition = scanner.getTokenPos();
parseExpected(SyntaxKind.OpenParenToken);
const expression = allowInAnd(parseExpression);
parseExpected(SyntaxKind.CloseParenToken);
parseExpectedMatchingBrackets(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken, openParenPosition);

// From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html
// 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in
Expand All @@ -5675,9 +5685,10 @@ namespace ts {
function parseWhileStatement(): WhileStatement {
const pos = getNodePos();
parseExpected(SyntaxKind.WhileKeyword);
const openParenPosition = scanner.getTokenPos();
parseExpected(SyntaxKind.OpenParenToken);
const expression = allowInAnd(parseExpression);
parseExpected(SyntaxKind.CloseParenToken);
parseExpectedMatchingBrackets(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken, openParenPosition);
const statement = parseStatement();
return finishNode(factory.createWhileStatement(expression, statement), pos);
}
Expand Down Expand Up @@ -5749,9 +5760,10 @@ namespace ts {
function parseWithStatement(): WithStatement {
const pos = getNodePos();
parseExpected(SyntaxKind.WithKeyword);
const openParenPosition = scanner.getTokenPos();
parseExpected(SyntaxKind.OpenParenToken);
const expression = allowInAnd(parseExpression);
parseExpected(SyntaxKind.CloseParenToken);
parseExpectedMatchingBrackets(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken, openParenPosition);
const statement = doInsideOfContext(NodeFlags.InWithStatement, parseStatement);
return finishNode(factory.createWithStatement(expression, statement), pos);
}
Expand Down Expand Up @@ -7973,13 +7985,9 @@ namespace ts {
hasChildren = true;
if (child.kind === SyntaxKind.JSDocTypeTag) {
if (childTypeTag) {
parseErrorAtCurrentToken(Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
const lastError = lastOrUndefined(parseDiagnostics);
const lastError = parseErrorAtCurrentToken(Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
if (lastError) {
addRelatedInfo(
lastError,
createDetachedDiagnostic(fileName, 0, 0, Diagnostics.The_tag_was_first_specified_here)
);
addRelatedInfo(lastError, createDetachedDiagnostic(fileName, 0, 0, Diagnostics.The_tag_was_first_specified_here));
}
break;
}
Expand Down Expand Up @@ -8011,7 +8019,7 @@ namespace ts {
}

const typedefTag = factory.createJSDocTypedefTag(tagName, typeExpression, fullName, comment);
return finishNode(typedefTag, start);
return finishNode(typedefTag, start, end);
}

function parseJSDocTypeNameWithNamespace(nested?: boolean) {
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/tsbuildPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1717,7 +1717,11 @@ namespace ts {
continue;
}
const outputs = getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames());
if (!outputs.length) continue;
const inputFileNames = new Set(parsed.fileNames.map(f => toPath(state, f)));
for (const output of outputs) {
// If output name is same as input file name, do not delete and ignore the error
if (inputFileNames.has(toPath(state, output))) continue;
if (host.fileExists(output)) {
if (filesToDelete) {
filesToDelete.push(output);
Expand Down
1 change: 0 additions & 1 deletion src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4353,7 +4353,6 @@ namespace ts {
InObjectTypeLiteral = 1 << 22,
InTypeAlias = 1 << 23, // Writing type in type alias declaration
InInitialEntityName = 1 << 24, // Set when writing the LHS of an entity name or entity name expression
InReverseMappedType = 1 << 25,
}

// Ensure the shared flags between this and `NodeBuilderFlags` stay in alignment
Expand Down
3 changes: 2 additions & 1 deletion src/harness/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ namespace ts.server {
fileName: entry.file,
textSpan: this.decodeSpan(entry),
kind: ScriptElementKind.unknown,
name: ""
name: "",
unverified: entry.unverified,
})),
textSpan: this.decodeSpan(body.textSpan, request.arguments.file)
};
Expand Down
2 changes: 0 additions & 2 deletions src/harness/compilerImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ namespace compiler {
}
}
}

this.diagnostics = diagnostics;
}

public get vfs(): vfs.FileSystem {
Expand Down

0 comments on commit 2090c0f

Please sign in to comment.