Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions 15 src/harness/unittests/printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ namespace ts {

describe("printFile", () => {
const printsCorrectly = makePrintsCorrectly("printsFileCorrectly");
const sourceFile = createSourceFile("source.ts", `
// Avoid eagerly creating the sourceFile so that `createSourceFile` doesn't run unless one of these tests is run.
let sourceFile: SourceFile;
before(() => sourceFile = createSourceFile("source.ts", `
interface A<T> {
// comment1
readonly prop?: T;
Expand Down Expand Up @@ -48,8 +50,7 @@ namespace ts {

// comment10
function functionWithDefaultArgValue(argument: string = "defaultValue"): void { }
`, ScriptTarget.ES2015);

`, ScriptTarget.ES2015));
printsCorrectly("default", {}, printer => printer.printFile(sourceFile));
printsCorrectly("removeComments", { removeComments: true }, printer => printer.printFile(sourceFile));

Expand All @@ -59,7 +60,8 @@ namespace ts {

describe("printBundle", () => {
const printsCorrectly = makePrintsCorrectly("printsBundleCorrectly");
const bundle = createBundle([
let bundle: Bundle;
before(() => bundle = createBundle([
createSourceFile("a.ts", `
/*! [a.ts] */

Expand All @@ -72,14 +74,15 @@ namespace ts {
// comment1
const b = 2;
`, ScriptTarget.ES2015)
]);
]));
printsCorrectly("default", {}, printer => printer.printBundle(bundle));
printsCorrectly("removeComments", { removeComments: true }, printer => printer.printBundle(bundle));
});

describe("printNode", () => {
const printsCorrectly = makePrintsCorrectly("printsNodeCorrectly");
const sourceFile = createSourceFile("source.ts", "", ScriptTarget.ES2015);
let sourceFile: SourceFile;
before(() => sourceFile = createSourceFile("source.ts", "", ScriptTarget.ES2015));
// tslint:disable boolean-trivia
const syntheticNode = createClassDeclaration(
undefined,
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.