Define, not assign. ES2022 class fields go through ECMA-262's DefineField, which calls CreateDataPropertyOrThrow on the instance (static fields: on the constructor). A derived class does this right after super() returns, a base class before its constructor body. TypeScript's original emit assigned instead (this.x = 1 in the constructor), which runs inherited setters and skips fields without initializers.
useDefineForClassFields chooses. true keeps native fields (or emits Object.defineProperty below ES2022); false emits assignments. It defaults to true when target is ES2022 or later, and since the TS 6.0 default target is es2025, define semantics are the default on 6.0.3 and 7.0.2 (checked by emit). Node's type stripping keeps fields as written, so it always defines.
What define changes.
- A subclass that redeclares a base property,
data!: User, now definesdata = undefinedaftersuper(), wiping what the base constructor stored. TypeScript reports TS2612, only under define. - A field over an inherited accessor creates an own data property, so the setter never runs. TS2610 (and TS2611 for the reverse) has been reported regardless of the flag since 4.0.
declare fields (TS 3.7). declare data: User refines a property's type with no emit and no runtime property. Use it to narrow a base property, or for a property something else creates (a base constructor, Object.assign). It cannot have an initializer (TS1039) or be #private (TS18019).
static blocks (ES2022, TS 4.4). static { ... } runs once during class evaluation, interleaved in source order with static field initializers, with this bound to the class and access to its #private names. Use it for multi-statement setup, try/catch, or computed tables. Below ES2022 it is emitted as an IIFE after the class.