| 246 | |
| 247 | // Splits the escaped type arguments (`\\<…\\>`) that follow a type name from the rest of the line. |
| 248 | function splitTypeArguments(rest: string) { |
| 249 | if (!rest.startsWith('\\<')) { |
| 250 | return { typeArguments: undefined, after: rest } |
| 251 | } |
| 252 | let depth = 0 |
| 253 | for (let index = 0; index < rest.length; index++) { |
| 254 | if (rest.startsWith('\\<', index)) { |
| 255 | depth++ |
| 256 | } else if (rest.startsWith('\\>', index) && --depth === 0) { |
| 257 | return { |
| 258 | typeArguments: rest.slice(2, index), |
| 259 | after: rest.slice(index + 2), |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | return { typeArguments: undefined, after: rest } |
| 264 | } |
| 265 | |
| 266 | // The type page a `Parameters`/`Returns` type line refers to when the whole line is that one type |
| 267 | // (with an optional default value), looking through wrappers that only change how the value is |