| 49 | while (take("|") || take("&")) typeMember() |
| 50 | } |
| 51 | const typeMember = (): void => { |
| 52 | if (take("readonly") || take("typeof")) { |
| 53 | typeMember() |
| 54 | return |
| 55 | } |
| 56 | if (take("(")) { |
| 57 | type() |
| 58 | expect(")") |
| 59 | } else if (take("[")) { |
| 60 | list("]", () => { |
| 61 | take("...") |
| 62 | type() |
| 63 | take("?") |
| 64 | }) |
| 65 | } else if (take("{")) { |
| 66 | while (!take("}")) { |
| 67 | take("readonly") |
| 68 | if (take("[")) { |
| 69 | if (tokens[index]?.kind === "identifier" && tokens[index + 1]?.text === ":") { |
| 70 | identifier() |
| 71 | expect(":") |
| 72 | type() |
| 73 | } else { |
| 74 | expression() |
| 75 | } |
| 76 | expect("]") |
| 77 | } else if (tokens[index]?.kind === "identifier" || isLiteral(tokens[index])) { |
| 78 | index++ |
| 79 | } else { |
| 80 | fail() |
| 81 | } |
| 82 | take("?") |
| 83 | expect(":") |
| 84 | type() |
| 85 | if (!take(",") && !take(";") && !at("}")) fail() |
| 86 | } |
| 87 | } else if (take("-")) { |
| 88 | if (!isLiteral(tokens[index++])) fail() |
| 89 | } else if (isLiteral(tokens[index])) { |
| 90 | index++ |
| 91 | } else { |
| 92 | path() |
| 93 | if (take("<")) list(">", type) |
| 94 | } |
| 95 | while (take("[")) expect("]") |
| 96 | } |
| 97 | const expression = (): void => { |
| 98 | if (take("-") || take("+") || take("!")) { |
| 99 | expression() |