(type, context)
| 52394 | return context.truncating = context.approximateLength > ((context.flags & 1 /* NodeBuilderFlags.NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); |
| 52395 | } |
| 52396 | function typeToTypeNodeHelper(type, context) { |
| 52397 | if (cancellationToken && cancellationToken.throwIfCancellationRequested) { |
| 52398 | cancellationToken.throwIfCancellationRequested(); |
| 52399 | } |
| 52400 | var inTypeAlias = context.flags & 8388608 /* NodeBuilderFlags.InTypeAlias */; |
| 52401 | context.flags &= ~8388608 /* NodeBuilderFlags.InTypeAlias */; |
| 52402 | if (!type) { |
| 52403 | if (!(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { |
| 52404 | context.encounteredError = true; |
| 52405 | return undefined; // TODO: GH#18217 |
| 52406 | } |
| 52407 | context.approximateLength += 3; |
| 52408 | return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); |
| 52409 | } |
| 52410 | if (!(context.flags & 536870912 /* NodeBuilderFlags.NoTypeReduction */)) { |
| 52411 | type = getReducedType(type); |
| 52412 | } |
| 52413 | if (type.flags & 1 /* TypeFlags.Any */) { |
| 52414 | if (type.aliasSymbol) { |
| 52415 | return ts.factory.createTypeReferenceNode(symbolToEntityNameNode(type.aliasSymbol), mapToTypeNodes(type.aliasTypeArguments, context)); |
| 52416 | } |
| 52417 | if (type === unresolvedType) { |
| 52418 | return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), 3 /* SyntaxKind.MultiLineCommentTrivia */, "unresolved"); |
| 52419 | } |
| 52420 | context.approximateLength += 3; |
| 52421 | return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* SyntaxKind.IntrinsicKeyword */ : 130 /* SyntaxKind.AnyKeyword */); |
| 52422 | } |
| 52423 | if (type.flags & 2 /* TypeFlags.Unknown */) { |
| 52424 | return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); |
| 52425 | } |
| 52426 | if (type.flags & 4 /* TypeFlags.String */) { |
| 52427 | context.approximateLength += 6; |
| 52428 | return ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */); |
| 52429 | } |
| 52430 | if (type.flags & 8 /* TypeFlags.Number */) { |
| 52431 | context.approximateLength += 6; |
| 52432 | return ts.factory.createKeywordTypeNode(147 /* SyntaxKind.NumberKeyword */); |
| 52433 | } |
| 52434 | if (type.flags & 64 /* TypeFlags.BigInt */) { |
| 52435 | context.approximateLength += 6; |
| 52436 | return ts.factory.createKeywordTypeNode(158 /* SyntaxKind.BigIntKeyword */); |
| 52437 | } |
| 52438 | if (type.flags & 16 /* TypeFlags.Boolean */ && !type.aliasSymbol) { |
| 52439 | context.approximateLength += 7; |
| 52440 | return ts.factory.createKeywordTypeNode(133 /* SyntaxKind.BooleanKeyword */); |
| 52441 | } |
| 52442 | if (type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */)) { |
| 52443 | var parentSymbol = getParentOfSymbol(type.symbol); |
| 52444 | var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* SymbolFlags.Type */); |
| 52445 | if (getDeclaredTypeOfSymbol(parentSymbol) === type) { |
| 52446 | return parentName; |
| 52447 | } |
| 52448 | var memberName = ts.symbolName(type.symbol); |
| 52449 | if (ts.isIdentifierText(memberName, 0 /* ScriptTarget.ES3 */)) { |
| 52450 | return appendReferenceToType(parentName, ts.factory.createTypeReferenceNode(memberName, /*typeArguments*/ undefined)); |
| 52451 | } |
| 52452 | if (ts.isImportTypeNode(parentName)) { |
| 52453 | parentName.isTypeOf = true; // mutably update, node is freshly manufactured anyhow |
no test coverage detected
searching dependent graphs…