Skip to content

Commit

Permalink
Fix indentation through string manipulation.
Browse files Browse the repository at this point in the history
It is ugly.
  • Loading branch information
sandersn committed Jun 30, 2023
1 parent 2c4e3da commit d1bfa96
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 59 deletions.
3 changes: 2 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7440,7 +7440,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
node.typeArguments = factory.createNodeArray(typeArguments);
}
if (signature.declaration?.kind === SyntaxKind.JSDocSignature && signature.declaration.parent.kind === SyntaxKind.JSDocOverloadTag) {
addSyntheticLeadingComment(node, SyntaxKind.MultiLineCommentTrivia, getTextOfNode(signature.declaration.parent.parent, /*includeTrivia*/ true).slice(2, -2), /*hasTrailingNewLine*/ true);
const comment = getTextOfNode(signature.declaration.parent.parent, /*includeTrivia*/ true).slice(2, -2).split(/\r\n|\n|\r/).map(line => line.replace(/^\s+/, " ")).join("\n");
addSyntheticLeadingComment(node, SyntaxKind.MultiLineCommentTrivia, comment, /*hasTrailingNewLine*/ true);
}

cleanup?.();
Expand Down
32 changes: 16 additions & 16 deletions tests/baselines/reference/jsFileMethodOverloads.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,27 +108,27 @@ declare class Example<T> {
constructor(value: T);
value: T;
/**
* @overload
* @param {Example<number>} this
* @returns {'number'}
*/
* @overload
* @param {Example<number>} this
* @returns {'number'}
*/
getTypeName(this: Example<number>): 'number';
/**
* @overload
* @param {Example<string>} this
* @returns {'string'}
*/
* @overload
* @param {Example<string>} this
* @returns {'string'}
*/
getTypeName(this: Example<string>): 'string';
/**
* @template U
* @overload
* @param {(y: T) => U} fn
* @returns {U}
*/
* @template U
* @overload
* @param {(y: T) => U} fn
* @returns {U}
*/
transform<U>(fn: (y: T) => U): U;
/**
* @overload
* @returns {T}
*/
* @overload
* @returns {T}
*/
transform(): T;
}
84 changes: 42 additions & 42 deletions tests/baselines/reference/jsFileMethodOverloads2.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,53 +102,53 @@ declare class Example<T> {
constructor(value: T);
value: T;
/**
* @overload
* @param {Example<number>} this
* @returns {'number'}
*
* @overload
* @param {Example<string>} this
* @returns {'string'}
*
* @returns {string}
*/
* @overload
* @param {Example<number>} this
* @returns {'number'}
*
* @overload
* @param {Example<string>} this
* @returns {'string'}
*
* @returns {string}
*/
getTypeName(this: Example<number>): 'number';
/**
* @overload
* @param {Example<number>} this
* @returns {'number'}
*
* @overload
* @param {Example<string>} this
* @returns {'string'}
*
* @returns {string}
*/
* @overload
* @param {Example<number>} this
* @returns {'number'}
*
* @overload
* @param {Example<string>} this
* @returns {'string'}
*
* @returns {string}
*/
getTypeName(this: Example<string>): 'string';
/**
* @template U
* @overload
* @param {(y: T) => U} fn
* @returns {U}
*
* @overload
* @returns {T}
*
* @param {(y: T) => unknown} [fn]
* @returns {unknown}
*/
* @template U
* @overload
* @param {(y: T) => U} fn
* @returns {U}
*
* @overload
* @returns {T}
*
* @param {(y: T) => unknown} [fn]
* @returns {unknown}
*/
transform<U>(fn: (y: T) => U): U;
/**
* @template U
* @overload
* @param {(y: T) => U} fn
* @returns {U}
*
* @overload
* @returns {T}
*
* @param {(y: T) => unknown} [fn]
* @returns {unknown}
*/
* @template U
* @overload
* @param {(y: T) => U} fn
* @returns {U}
*
* @overload
* @returns {T}
*
* @param {(y: T) => unknown} [fn]
* @returns {unknown}
*/
transform<U>(): T;
}

0 comments on commit d1bfa96

Please sign in to comment.