(outputDir: string, code: string)
| 305 | |
| 306 | // The name of the type a signature's code starts with, looking through the same wrappers. |
| 307 | async function typeNameInCode(outputDir: string, code: string) { |
| 308 | let type = code |
| 309 | for (;;) { |
| 310 | type = type.replace(/^\(\) => /, '') |
| 311 | const name = type.match(/^\w+/)?.[0] |
| 312 | if ( |
| 313 | !name || |
| 314 | type[name.length] !== '<' || |
| 315 | !(await isWrapperAlias(outputDir, `type-aliases/${name}`)) |
| 316 | ) { |
| 317 | return name |
| 318 | } |
| 319 | let depth = 0 |
| 320 | for (let index = name.length; index < type.length; index++) { |
| 321 | if (type[index] === '<') { |
| 322 | depth++ |
| 323 | } else if ( |
| 324 | type[index] === '>' && |
| 325 | type[index - 1] !== '=' && |
| 326 | --depth === 0 |
| 327 | ) { |
| 328 | type = type.slice(name.length + 1, index) |
| 329 | break |
| 330 | } |
| 331 | } |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | // The parameter and return types of the declaration a call signature's "Defined in" line points to, as |
| 336 | // written in the source. The rendered code loses aliases that TypeScript flattens into an intersection, |
no test coverage detected