@@ -2278,35 +2278,10 @@ namespace ts {
22782278 return result;
22792279 }
22802280
2281- function typeFormatFlagsToNodeBuilderFlags(flags: TypeFormatFlags): NodeBuilderFlags {
2282- let result = NodeBuilderFlags.None;
2283- if (flags === TypeFormatFlags.None) {
2284- return result;
2285- }
2286- if (flags & TypeFormatFlags.NoTruncation) {
2287- result |= NodeBuilderFlags.NoTruncation;
2288- }
2289- if (flags & TypeFormatFlags.UseFullyQualifiedType) {
2290- result |= NodeBuilderFlags.UseFullyQualifiedType;
2291- }
2292- if (flags & TypeFormatFlags.SuppressAnyReturnType) {
2293- result |= NodeBuilderFlags.SuppressAnyReturnType;
2294- }
2295- if (flags & TypeFormatFlags.WriteArrayAsGenericType) {
2296- result |= NodeBuilderFlags.WriteArrayAsGenericType;
2297- }
2298- if (flags & TypeFormatFlags.WriteTypeArgumentsOfSignature) {
2299- result |= NodeBuilderFlags.WriteTypeArgumentsOfSignature;
2300- }
2301-
2302- return result;
2303- }
2304-
23052281 function typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string {
2306- const typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, typeFormatFlagsToNodeBuilderFlags (flags) | NodeBuilderFlags.ignoreErrors);
2282+ const typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags (flags) | NodeBuilderFlags.ignoreErrors);
23072283 Debug.assert(typeNode !== undefined, "should always get typenode?");
2308- const newLine = NewLineKind.None;
2309- const options = { newLine, removeComments: true };
2284+ const options = { removeComments: true };
23102285 const writer = createTextWriter("");
23112286 const printer = createPrinter(options, writer);
23122287 const sourceFile = enclosingDeclaration && getSourceFileOfNode(enclosingDeclaration);
@@ -2318,6 +2293,30 @@ namespace ts {
23182293 return result.substr(0, maxLength - "...".length) + "...";
23192294 }
23202295 return result;
2296+
2297+ function toNodeBuilderFlags(flags?: TypeFormatFlags): NodeBuilderFlags {
2298+ let result = NodeBuilderFlags.None;
2299+ if (!flags) {
2300+ return result;
2301+ }
2302+ if (flags & TypeFormatFlags.NoTruncation) {
2303+ result |= NodeBuilderFlags.NoTruncation;
2304+ }
2305+ if (flags & TypeFormatFlags.UseFullyQualifiedType) {
2306+ result |= NodeBuilderFlags.UseFullyQualifiedType;
2307+ }
2308+ if (flags & TypeFormatFlags.SuppressAnyReturnType) {
2309+ result |= NodeBuilderFlags.SuppressAnyReturnType;
2310+ }
2311+ if (flags & TypeFormatFlags.WriteArrayAsGenericType) {
2312+ result |= NodeBuilderFlags.WriteArrayAsGenericType;
2313+ }
2314+ if (flags & TypeFormatFlags.WriteTypeArgumentsOfSignature) {
2315+ result |= NodeBuilderFlags.WriteTypeArgumentsOfSignature;
2316+ }
2317+
2318+ return result;
2319+ }
23212320 }
23222321
23232322 function createNodeBuilder() {
@@ -2423,7 +2422,7 @@ namespace ts {
24232422 }
24242423 if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) {
24252424 if (context.flags & NodeBuilderFlags.inObjectTypeLiteral) {
2426- if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowThisInObjectLiteral )) {
2425+ if (!context.encounteredError && !(context.flags & NodeBuilderFlags.AllowThisInObjectLiteral )) {
24272426 context.encounteredError = true;
24282427 }
24292428 }
@@ -2455,7 +2454,7 @@ namespace ts {
24552454 return inElementType ? createParenthesizedType(unionOrIntersectionTypeNode) : unionOrIntersectionTypeNode;
24562455 }
24572456 else {
2458- if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowEmptyUnionOrIntersection )) {
2457+ if (!context.encounteredError && !(context.flags & NodeBuilderFlags.AllowEmptyUnionOrIntersection )) {
24592458 context.encounteredError = true;
24602459 }
24612460 return undefined;
@@ -2629,7 +2628,7 @@ namespace ts {
26292628 return createTupleTypeNode(tupleConstituentNodes);
26302629 }
26312630 }
2632- if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowEmptyTuple )) {
2631+ if (!context.encounteredError && !(context.flags & NodeBuilderFlags.AllowEmptyTuple )) {
26332632 context.encounteredError = true;
26342633 }
26352634 return undefined;
@@ -2901,7 +2900,7 @@ namespace ts {
29012900
29022901 if (expectsIdentifier && chain.length !== 1
29032902 && !context.encounteredError
2904- && !(context.flags & NodeBuilderFlags.allowQualifedNameInPlaceOfIdentifier )) {
2903+ && !(context.flags & NodeBuilderFlags.AllowQualifedNameInPlaceOfIdentifier )) {
29052904 context.encounteredError = true;
29062905 }
29072906 return createEntityNameFromSymbolChain(chain, chain.length - 1);
@@ -2923,7 +2922,7 @@ namespace ts {
29232922 }
29242923 }
29252924 if (typeParameters && typeParameters.length > 0) {
2926- if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowTypeParameterInQualifiedName )) {
2925+ if (!context.encounteredError && !(context.flags & NodeBuilderFlags.AllowTypeParameterInQualifiedName )) {
29272926 context.encounteredError = true;
29282927 }
29292928 typeParameterNodes = toTypeArgumentNodes(typeParameters, context);
@@ -2981,7 +2980,7 @@ namespace ts {
29812980 if (declaration.parent && declaration.parent.kind === SyntaxKind.VariableDeclaration) {
29822981 return declarationNameToString((<VariableDeclaration>declaration.parent).name);
29832982 }
2984- if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowAnonymousIdentifier )) {
2983+ if (!context.encounteredError && !(context.flags & NodeBuilderFlags.AllowAnonymousIdentifier )) {
29852984 context.encounteredError = true;
29862985 }
29872986 switch (declaration.kind) {
0 commit comments