Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leading and trailing trivia aren't written for overloads of function declarations #1244

Closed
FredericEspiau opened this issue Feb 12, 2022 · 1 comment
Labels

Comments

@FredericEspiau
Copy link

FredericEspiau commented Feb 12, 2022

Version: 13.0.1

Leading and trailing trivia aren't written for overloads of function declarations

To Reproduce

import { Project } from "ts-morph";

const project = new Project();
const sourceFile = project.createSourceFile("test.ts", ``);

source.addFunction({
  leadingTrivia: "// leading trivia function",
  trailingTrivia: "// trailing trivia function",
  overloads: [     
    {
        leadingTrivia: "// leading trivia overload",
        trailingTrivia: "// trailing trivia overload",
        returnType: "string",
    },
  ],
  name: "functionName",
  statements: "return 'hello';",
});
project.saveSync();

Actual behavior

// leading trivia function
function functionName(): string;
function functionName() {
    return 'hello';
}// trailing trivia function

Expected behavior

// leading trivia overload
function functionName(): string;// trailing trivia overload
// leading trivia function
function functionName() {
    return 'hello';
}// trailing trivia function
@FredericEspiau
Copy link
Author

Wonderful thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants