* Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym`
(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled)
| 53915 | * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` |
| 53916 | */ |
| 53917 | function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) { |
| 53918 | if (!isErrorType(type) && enclosingDeclaration) { |
| 53919 | var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration); |
| 53920 | if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) { |
| 53921 | // try to reuse the existing annotation |
| 53922 | var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); |
| 53923 | if (typeNodeIsEquivalentToType(existing, declWithExistingAnnotation, type) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { |
| 53924 | var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); |
| 53925 | if (result_6) { |
| 53926 | return result_6; |
| 53927 | } |
| 53928 | } |
| 53929 | } |
| 53930 | } |
| 53931 | var oldFlags = context.flags; |
| 53932 | if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && |
| 53933 | type.symbol === symbol && (!context.enclosingDeclaration || ts.some(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); }))) { |
| 53934 | context.flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; |
| 53935 | } |
| 53936 | var result = typeToTypeNodeHelper(type, context); |
| 53937 | context.flags = oldFlags; |
| 53938 | return result; |
| 53939 | } |
| 53940 | function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) { |
| 53941 | var typeFromTypeNode = getTypeFromTypeNode(typeNode); |
| 53942 | if (typeFromTypeNode === type) { |
no test coverage detected
searching dependent graphs…