mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-19 08:24:15 -06:00
JSDoc:... binds tighter than *n* postfix jsdocs
1. Previously ...X? mistakenly parsed as ...(X?) instead of (...X)? 2. Previously X?!?!? mistakenly failed to parse the postfix tokens ? ! ? ! ? at the same level of precedence. The fix is to 1. Make ... parsing call parseNonArrayType instead of parseType. 2. Make postfix jsdoc parsing parse in a loop instead of only parsing one token.
This commit is contained in:
parent
450c32ace0
commit
c746477d81
@ -2178,7 +2178,7 @@ namespace ts {
|
||||
function parseJSDocNodeWithType(kind: SyntaxKind.JSDocVariadicType | SyntaxKind.JSDocNonNullableType): TypeNode {
|
||||
const result = createNode(kind) as JSDocVariadicType | JSDocNonNullableType;
|
||||
nextToken();
|
||||
result.type = parseType();
|
||||
result.type = parseNonArrayType();
|
||||
return finishNode(result);
|
||||
}
|
||||
|
||||
@ -2740,14 +2740,15 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseJSDocPostfixTypeOrHigher(): TypeNode {
|
||||
const type = parseNonArrayType();
|
||||
const kind = getKind(token());
|
||||
if (!kind) return type;
|
||||
nextToken();
|
||||
|
||||
const postfix = createNode(kind, type.pos) as JSDocOptionalType | JSDocNonNullableType | JSDocNullableType;
|
||||
postfix.type = type;
|
||||
return finishNode(postfix);
|
||||
let kind: SyntaxKind | undefined;
|
||||
let type = parseNonArrayType();
|
||||
while (kind = getKind(token())) {
|
||||
nextToken();
|
||||
const postfix = createNode(kind, type.pos) as JSDocOptionalType | JSDocNonNullableType | JSDocNullableType;
|
||||
postfix.type = type;
|
||||
type = finishNode(postfix);
|
||||
}
|
||||
return type;
|
||||
|
||||
function getKind(tokenKind: SyntaxKind): SyntaxKind | undefined {
|
||||
switch (tokenKind) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user