Skip to content

codegen: preserve some comments #24324

Description

@romain-trotard

Hello :)

This bug is similar to codegen: preserve comments between CatchClause's param and body
but with some other cases that I discovered in my codebase.

Code coverage tooling that support ignore next ignore hint need code transforms to preserve some comments, you can see all the cases that I discovered in this playground

Here is the content :

Input

function myFunction(a) {
  const nullishCoalescing = a ?? /* istanbul ignore next */ [];
  const ternary = a ? /* istanbul ignore next */ 'first' : 'second';
  const value = a && /* istanbul ignore next */ 'otherValue';
}

const myObject = {
  aFunction: /* istanbul ignore next */ () => {}
}

Expected output

function myFunction(a) {
	const nullishCoalescing = a ?? /* istanbul ignore next */ [];
	const ternary = a ? /* istanbul ignore next */ "first" : "second";
	const value = a && /* istanbul ignore next */ "otherValue";
}
const myObject = { aFunction: /* istanbul ignore next */ () => {} };

Actual output

function myFunction(a) {
	const nullishCoalescing = a ?? [];
	const ternary = a ? "first" : "second";
	const value = a && "otherValue";
}
const myObject = { aFunction: () => {} };

Thanks

Metadata

Metadata

Assignees

Labels

A-codegenArea - Code Generation

Type

Fields

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions