( type: TSType | TSTypeAnnotation, context: TypeContext, module: SourceModule, kindOfKey: KindOfKey, depth = 0, typeArgs?: TypeArgs, state: TypeEvalState = newTypeEvalState() )
| 2088 | } |
| 2089 | |
| 2090 | private typeKindOf( |
| 2091 | type: TSType | TSTypeAnnotation, |
| 2092 | context: TypeContext, |
| 2093 | module: SourceModule, |
| 2094 | kindOfKey: KindOfKey, |
| 2095 | depth = 0, |
| 2096 | typeArgs?: TypeArgs, |
| 2097 | state: TypeEvalState = newTypeEvalState() |
| 2098 | ): KindBits | undefined { |
| 2099 | if (state.aborted || ++state.steps > maxTypeSteps) { |
| 2100 | state.aborted = true |
| 2101 | return |
| 2102 | } |
| 2103 | const union = ( |
| 2104 | types: (TSType | TSTypeAnnotation | null)[], |
| 2105 | depth: number |
| 2106 | ) => |
| 2107 | this.unionKindOf( |
| 2108 | types, |
| 2109 | context, |
| 2110 | module, |
| 2111 | kindOfKey, |
| 2112 | depth, |
| 2113 | typeArgs, |
| 2114 | state |
| 2115 | ) |
| 2116 | switch (type.type) { |
| 2117 | case "TSTypeAnnotation": |
| 2118 | case "TSParenthesizedType": |
| 2119 | return this.typeKindOf( |
| 2120 | type.typeAnnotation, |
| 2121 | context, |
| 2122 | module, |
| 2123 | kindOfKey, |
| 2124 | depth, |
| 2125 | typeArgs, |
| 2126 | state |
| 2127 | ) |
| 2128 | case "TSAnyKeyword": |
| 2129 | return |
| 2130 | // says nothing at the top level, but data where nested |
| 2131 | case "TSUnknownKeyword": |
| 2132 | case "TSObjectKeyword": |
| 2133 | return depth < 2 ? undefined : kinds.data |
| 2134 | case "TSUnionType": |
| 2135 | return union(type.types, depth) |
| 2136 | case "TSConditionalType": |
| 2137 | return hasInferType(type.extendsType) ? undefined : ( |
| 2138 | union([type.trueType, type.falseType], depth) |
| 2139 | ) |
| 2140 | case "TSIntersectionType": |
| 2141 | return this.intersectionKindOf( |
| 2142 | type, |
| 2143 | context, |
| 2144 | module, |
| 2145 | kindOfKey, |
| 2146 | depth, |
| 2147 | typeArgs, |
no test coverage detected