( callable: TSFunctionType | TSMethodSignature, index: number )
| 7029 | } |
| 7030 | |
| 7031 | const paramTypeAt = ( |
| 7032 | callable: TSFunctionType | TSMethodSignature, |
| 7033 | index: number |
| 7034 | ): TSType | undefined => { |
| 7035 | const params = callable.params.filter( |
| 7036 | (param, i) => |
| 7037 | !(i === 0 && param.type === "Identifier" && param.name === "this") |
| 7038 | ) |
| 7039 | const param = params[index] |
| 7040 | if (param) { |
| 7041 | const target = param.type === "AssignmentPattern" ? param.left : param |
| 7042 | if (target.type === "RestElement") { |
| 7043 | const restType = target.typeAnnotation?.typeAnnotation |
| 7044 | return restType?.type === "TSArrayType" ? restType.elementType : undefined |
| 7045 | } |
| 7046 | return "typeAnnotation" in target ? |
| 7047 | target.typeAnnotation?.typeAnnotation |
| 7048 | : undefined |
| 7049 | } |
| 7050 | const last = params[params.length - 1] |
| 7051 | if (last?.type === "RestElement") { |
| 7052 | const restType = last.typeAnnotation?.typeAnnotation |
| 7053 | return restType?.type === "TSArrayType" ? restType.elementType : undefined |
| 7054 | } |
| 7055 | } |
| 7056 | |
| 7057 | // true if every literal key in `type` includes `name`, false if none does, |
| 7058 | // undefined if `type` is not a string literal or union of string literals |
no test coverage detected