(t *Type)
| 3174 | } |
| 3175 | |
| 3176 | func (b *NodeBuilderImpl) typeToTypeNode(t *Type) *ast.TypeNode { |
| 3177 | // Push type onto typeStack for expansion depth tracking |
| 3178 | if b.ctx.maxExpansionDepth >= 0 && t != nil { |
| 3179 | b.ctx.typeStack = append(b.ctx.typeStack, t) |
| 3180 | defer func() { |
| 3181 | b.ctx.typeStack = b.ctx.typeStack[:len(b.ctx.typeStack)-1] |
| 3182 | }() |
| 3183 | } |
| 3184 | |
| 3185 | inTypeAlias := b.ctx.flags & nodebuilder.FlagsInTypeAlias |
| 3186 | b.ctx.flags &^= nodebuilder.FlagsInTypeAlias |
| 3187 | |
| 3188 | if t == nil { |
| 3189 | if b.ctx.flags&nodebuilder.FlagsAllowEmptyUnionOrIntersection == 0 { |
| 3190 | b.ctx.encounteredError = true |
| 3191 | return nil |
| 3192 | // TODO: GH#18217 |
| 3193 | } |
| 3194 | b.ctx.approximateLength += 3 |
| 3195 | return b.f.NewKeywordTypeNode(ast.KindAnyKeyword) |
| 3196 | } |
| 3197 | |
| 3198 | if b.ctx.flags&nodebuilder.FlagsNoTypeReduction == 0 { |
| 3199 | t = b.ch.getReducedType(t) |
| 3200 | } |
| 3201 | |
| 3202 | if t.flags&TypeFlagsAny != 0 { |
| 3203 | if t.alias != nil { |
| 3204 | return t.alias.ToTypeReferenceNode(b) |
| 3205 | } |
| 3206 | if t == b.ch.unresolvedType { |
| 3207 | return b.e.AddSyntheticLeadingComment(b.f.NewKeywordTypeNode(ast.KindAnyKeyword), ast.KindMultiLineCommentTrivia, "unresolved", false /*hasTrailingNewLine*/) |
| 3208 | } |
| 3209 | b.ctx.approximateLength += 3 |
| 3210 | return b.f.NewKeywordTypeNode(core.IfElse(t == b.ch.intrinsicMarkerType, ast.KindIntrinsicKeyword, ast.KindAnyKeyword)) |
| 3211 | } |
| 3212 | if t.flags&TypeFlagsUnknown != 0 { |
| 3213 | return b.f.NewKeywordTypeNode(ast.KindUnknownKeyword) |
| 3214 | } |
| 3215 | if t.flags&TypeFlagsString != 0 { |
| 3216 | b.ctx.approximateLength += 6 |
| 3217 | return b.f.NewKeywordTypeNode(ast.KindStringKeyword) |
| 3218 | } |
| 3219 | if t.flags&TypeFlagsNumber != 0 { |
| 3220 | b.ctx.approximateLength += 6 |
| 3221 | return b.f.NewKeywordTypeNode(ast.KindNumberKeyword) |
| 3222 | } |
| 3223 | if t.flags&TypeFlagsBigInt != 0 { |
| 3224 | b.ctx.approximateLength += 6 |
| 3225 | return b.f.NewKeywordTypeNode(ast.KindBigIntKeyword) |
| 3226 | } |
| 3227 | if t.flags&TypeFlagsBoolean != 0 && t.alias == nil { |
| 3228 | b.ctx.approximateLength += 7 |
| 3229 | return b.f.NewKeywordTypeNode(ast.KindBooleanKeyword) |
| 3230 | } |
| 3231 | expandingEnum := false |
| 3232 | if t.flags&TypeFlagsEnumLike != 0 { |
| 3233 | if t.symbol.Flags&ast.SymbolFlagsEnumMember != 0 { |
no test coverage detected