TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

FR: Add TS config option to disable "<some regex feature> is only available when targeting 'es2018' or later.".

Open lauraharker opened this issue 1 year ago • 0 comments

Acknowledgement

  • [X] I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.

Comment

Search terms for existing issues

"regex", "regular expressions"

Problem

The Google TS build infrastructure runs the TypeScript compiler with a centrally defined target language = "ES2016" for edit-refresh & testing. For production, users can still target newer language versions, but for various reasons our edit-refresh setup is stuck on this older language version.

This means that with TS 5.5 we start seeing build errors like "This regular expression flag is only available when targeting 'es2018' or later.".

Our current workaround will be either using the RegExp constructor or adding a patch to our compiler fork.

Proposal

Add a TS config option to toggle whether these sorts of errors are emitted at all.

Use cases

I realize that Google infra's situation is unusual, so this might not be a generally useful proposal & understand if you don't support this.

However, some possibilities I could imagine for someone setting an older target language than necessary for the browsers they support might be:

  • dependance on some semantics of the transpiled code, e.g. because of https://github.com/angular/angular/issues/31730
  • some other part of the build toolchain not supporting newer syntax.

lauraharker avatar Jun 28 '24 18:06 lauraharker