From f83a29e99324b3dc1a87c7648e88d37fb944d7b8 Mon Sep 17 00:00:00 2001 From: Keith Henry Date: Wed, 8 Sep 2021 07:25:24 +0100 Subject: [PATCH] Documented useDefineForClassFields useDefineForClassFields is incompatible with experimentalDecorators, see https://github.com/lit/lit/issues/1985 --- .../site/docs/components/decorators.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/lit-dev-content/site/docs/components/decorators.md b/packages/lit-dev-content/site/docs/components/decorators.md index 75e53055f..9524e6bd4 100644 --- a/packages/lit-dev-content/site/docs/components/decorators.md +++ b/packages/lit-dev-content/site/docs/components/decorators.md @@ -79,6 +79,17 @@ To use decorators with [TypeScript](https://www.typescriptlang.org/docs/handbook Enabling `emitDecoratorMetadata` is not required and not recommended. +For TypeScript 3.7 and above a new flag `useDefineForClassFields` is incompatible with property decorators, and for 4.3 when the `target` is `es2020` or higher it defaults to true. + +There are two ways to work around this incompatability: either add a compiler option to force it off: + +```json +"experimentalDecorators": true, +"useDefineForClassFields": false, +``` + +Alternatively `useDefineForClassFields` _can_ be used if every decorator annotated property uses `declare`. + ### Using decorators with Babel { #decorators-babel } If you're compiling JavaScript with [Babel](https://babeljs.io/docs/en/), you can enable decorators by adding the following plugins: