Change from 'bracelss' to 'mayOmitBraces'
This commit is contained in:
parent
298a5f0e2d
commit
ff94f2da30
|
@ -1160,7 +1160,9 @@ namespace ts {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toArray<T>(value: T | ReadonlyArray<T>): ReadonlyArray<T> {
|
export function toArray<T>(value: T | ReadonlyArray<T>): ReadonlyArray<T>;
|
||||||
|
export function toArray<T>(value: T | T[]): T[];
|
||||||
|
export function toArray<T>(value: T | T[]): T[] {
|
||||||
return isArray(value) ? value : [value];
|
return isArray(value) ? value : [value];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1366,10 +1368,6 @@ namespace ts {
|
||||||
return Array.isArray ? Array.isArray(value) : value instanceof Array;
|
return Array.isArray ? Array.isArray(value) : value instanceof Array;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toArray<T>(value: T | T[]): T[] {
|
|
||||||
return isArray(value) ? value : [value];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether a value is string
|
* Tests whether a value is string
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6132,14 +6132,12 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parses out a JSDoc type expression.
|
// Parses out a JSDoc type expression.
|
||||||
export function parseJSDocTypeExpression(braceless?: boolean): JSDocTypeExpression {
|
export function parseJSDocTypeExpression(mayOmitBraces?: boolean): JSDocTypeExpression {
|
||||||
const result = <JSDocTypeExpression>createNode(SyntaxKind.JSDocTypeExpression, scanner.getTokenPos());
|
const result = <JSDocTypeExpression>createNode(SyntaxKind.JSDocTypeExpression, scanner.getTokenPos());
|
||||||
|
|
||||||
if (!braceless) {
|
const sawBrace = (mayOmitBraces ? parseOptional : parseExpected)(SyntaxKind.OpenBraceToken);
|
||||||
parseExpected(SyntaxKind.OpenBraceToken);
|
|
||||||
}
|
|
||||||
result.type = doInsideOfContext(NodeFlags.JSDoc, parseType);
|
result.type = doInsideOfContext(NodeFlags.JSDoc, parseType);
|
||||||
if (!braceless) {
|
if (!mayOmitBraces || sawBrace) {
|
||||||
parseExpected(SyntaxKind.CloseBraceToken);
|
parseExpected(SyntaxKind.CloseBraceToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6486,9 +6484,9 @@ namespace ts {
|
||||||
tagsEnd = tag.end;
|
tagsEnd = tag.end;
|
||||||
}
|
}
|
||||||
|
|
||||||
function tryParseTypeExpression(bracelessFallback?: boolean): JSDocTypeExpression | undefined {
|
function tryParseTypeExpression(): JSDocTypeExpression | undefined {
|
||||||
skipWhitespace();
|
skipWhitespace();
|
||||||
return token() === SyntaxKind.OpenBraceToken ? parseJSDocTypeExpression() : bracelessFallback && parseJSDocTypeExpression(/*braceless*/ true);
|
return token() === SyntaxKind.OpenBraceToken ? parseJSDocTypeExpression() : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseBracketNameInPropertyAndParamTag(): { name: EntityName, isBracketed: boolean } {
|
function parseBracketNameInPropertyAndParamTag(): { name: EntityName, isBracketed: boolean } {
|
||||||
|
@ -6597,7 +6595,7 @@ namespace ts {
|
||||||
const result = <JSDocTypeTag>createNode(SyntaxKind.JSDocTypeTag, atToken.pos);
|
const result = <JSDocTypeTag>createNode(SyntaxKind.JSDocTypeTag, atToken.pos);
|
||||||
result.atToken = atToken;
|
result.atToken = atToken;
|
||||||
result.tagName = tagName;
|
result.tagName = tagName;
|
||||||
result.typeExpression = tryParseTypeExpression(/*bracketlessFallback*/ true);
|
result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true);
|
||||||
return finishNode(result);
|
return finishNode(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,8 @@ namespace ts {
|
||||||
Debug.fail("Comment failed to parse entirely");
|
Debug.fail("Comment failed to parse entirely");
|
||||||
}
|
}
|
||||||
if (comment.diagnostics.length > 0) {
|
if (comment.diagnostics.length > 0) {
|
||||||
Debug.fail("Comment has at least one diagnostic: " + comment.diagnostics[0].messageText);
|
const diag = comment.diagnostics[0];
|
||||||
|
Debug.fail("Comment has at least one diagnostic: " + diag.messageText + " at " + diag.start);
|
||||||
}
|
}
|
||||||
|
|
||||||
Harness.Baseline.runBaseline("JSDocParsing/DocComments.parsesCorrectly." + name + ".json",
|
Harness.Baseline.runBaseline("JSDocParsing/DocComments.parsesCorrectly." + name + ".json",
|
||||||
|
|
Loading…
Reference in a new issue