Function tsDocFixSpacingBeforeAfter

  • This function fixes the spacing before and after the code in a TypeScript file. It replaces multiple newlines after a block comment end with a single newline. It also ensures that there is a newline before the start of a block comment if there is any non-whitespace character before it.

    Parameters

    • code: string

      The TypeScript code to fix the spacing for.

    Returns string

    The TypeScript code with fixed spacing.

    Example

    const code = `
    function example() {
    // some code
    }
    /**
    * This is a comment.
    */
    function anotherExample() {
    // some more code
    }
    `;
    const fixedCode = tsDocFixSpacingBeforeAfter(code);
    //=> fixedCode

Generated using TypeDoc