Yohsuke Inoda
Yohsuke Inoda

Reputation: 541

How to preserve license comments in TypeScript 2.5

I create JavaScript libraries using TypeScript v2.5 (latest) and tsc, so want to add license comments to built files. A configuration file of TypeScript can be set removeComments in tsconfig.json . It removes some comments including license comments.

I've referred this post and tried to use /** xxx */ and /*! xxx */ , but the comments are removed. What should I do to preserve specific comments in TypeScript using removeComments option? Or it has been gone yet?

// Source
/** Hello! */
/* Hi */
class Foo { }

// Expected
/* Hello! */
class Foo { }

// Actual
class Foo { }

Upvotes: 1

Views: 609

Answers (2)

Yohsuke Inoda
Yohsuke Inoda

Reputation: 541

/*! xxx */ does work but only one line. If preserve multiple lines, should add dummy comments below the comments.

// This will be removed
/*!
 *
 *  LICENSE
 *
 */

// This will not be removed
/*!
 *
 *  LICENSE
 *
 */
/* --------------------------- */

Thanks, everyone!

Upvotes: 2

J_H
J_H

Reputation: 20495

Perhaps you'd like to make an assignment of license = "[very long boilerplate]"; ?

Upvotes: 0

Related Questions