From 9e0b496f75c71245fbfe7c9adaf9169ae33a7314 Mon Sep 17 00:00:00 2001 From: yusufyildiz34 Date: Fri, 6 Nov 2026 13:17:05 -0500 Subject: [PATCH] Fix ES decorator metadata crash when class extends null The downleveled decorator metadata code read `_classSuper[Symbol.metadata]`, which throws a TypeError when the superclass is `null` (`class C extends null {}`), so the module failed to load. Emit `_classSuper?.[Symbol.metadata] ?? null` instead, so a null superclass gives a null parent metadata object, as the decorator metadata proposal specifies. Targets below ES2020 get the existing optional chaining and nullish coalescing downlevel. --- .../transformers/estransforms/esdecorator.go | 4 +- .../compiler/esDecoratorExtendsNull.js | 2 +- ...rimentaldecorators=false,target=es2015).js | 2 +- ...rimentaldecorators=false,target=es2022).js | 2 +- ...estructuringInDecoratedClassStaticBlock.js | 2 +- ...ecorators-classDeclaration-classSuper.1.js | 2 +- ...ecorators-classDeclaration-classSuper.2.js | 6 +- ...ecorators-classDeclaration-classSuper.3.js | 2 +- ...ecorators-classDeclaration-classSuper.4.js | 2 +- ...ecorators-classDeclaration-classSuper.5.js | 6 +- ...ecorators-classDeclaration-classSuper.6.js | 2 +- ...ecorators-classDeclaration-classSuper.7.js | 4 +- ...Decorators-classExpression-classSuper.1.js | 2 +- ...Decorators-classExpression-classSuper.2.js | 6 +- ...Decorators-classExpression-classSuper.3.js | 2 +- ...Decorators-classExpression-classSuper.4.js | 2 +- ...Decorators-classExpression-classSuper.5.js | 6 +- ...Decorators-classExpression-classSuper.6.js | 2 +- .../esDecoratorsMetadata2(target=es2015).js | 2 +- .../esDecoratorsMetadata2(target=es2022).js | 2 +- .../esDecoratorsMetadata3(target=es2015).js | 2 +- .../esDecoratorsMetadata3(target=es2022).js | 2 +- .../esDecoratorsMetadata6(target=es2015).js | 113 ++++++++++++++++++ .../esDecoratorsMetadata6(target=es2022).js | 107 +++++++++++++++++ .../metadata/esDecoratorsMetadata6.ts | 27 +++++ 25 files changed, 280 insertions(+), 31 deletions(-) create mode 100644 tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata6(target=es2015).js create mode 100644 tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata6(target=es2022).js create mode 100644 tsc/testdata/tests/cases/conformance/esDecorators/metadata/esDecoratorsMetadata6.ts diff --git a/tsc/internal/transformers/estransforms/esdecorator.go b/tsc/internal/transformers/estransforms/esdecorator.go index 6c2372cf2f4bc..ae42be145c31c 100644 --- a/tsc/internal/transformers/estransforms/esdecorator.go +++ b/tsc/internal/transformers/estransforms/esdecorator.go @@ -2711,8 +2711,10 @@ func (tx *esDecoratorTransformer) createSymbolMetadata(target *ast.Expression, v func (tx *esDecoratorTransformer) createSymbolMetadataReference(classSuper *ast.IdentifierNode) *ast.Expression { f := tx.Factory() + // _classSuper?.[Symbol.metadata] ?? null + // The superclass may be `null` (`class C extends null {}`), in which case the parent metadata is `null`. symbolMetadata := f.NewPropertyAccessExpression(f.NewIdentifier("Symbol"), nil, f.NewIdentifier("metadata"), ast.NodeFlagsNone) - elementAccess := f.NewElementAccessExpression(classSuper, nil, symbolMetadata, ast.NodeFlagsNone) + elementAccess := f.NewElementAccessExpression(classSuper, f.NewToken(ast.KindQuestionDotToken), symbolMetadata, ast.NodeFlagsOptionalChain) return f.NewBinaryExpression(nil, elementAccess, nil, f.NewToken(ast.KindQuestionQuestionToken), f.NewToken(ast.KindNullKeyword)) } diff --git a/tsc/testdata/baselines/reference/compiler/esDecoratorExtendsNull.js b/tsc/testdata/baselines/reference/compiler/esDecoratorExtendsNull.js index b32136b3e3345..8f4f5ddca552f 100644 --- a/tsc/testdata/baselines/reference/compiler/esDecoratorExtendsNull.js +++ b/tsc/testdata/baselines/reference/compiler/esDecoratorExtendsNull.js @@ -23,7 +23,7 @@ let C = (() => { let _x_extraInitializers = []; return class C extends _classSuper { static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; _x_decorators = [dec]; __esDecorate(null, null, _x_decorators, { kind: "field", name: "x", static: false, private: false, access: { has: obj => "x" in obj, get: obj => obj.x, set: (obj, value) => { obj.x = value; } }, metadata: _metadata }, _x_initializers, _x_extraInitializers); if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/compiler/malformedDestructuringAssignmentTransformVariants(experimentaldecorators=false,target=es2015).js b/tsc/testdata/baselines/reference/compiler/malformedDestructuringAssignmentTransformVariants(experimentaldecorators=false,target=es2015).js index 5092f63eb2549..a657f88603cd5 100644 --- a/tsc/testdata/baselines/reference/compiler/malformedDestructuringAssignmentTransformVariants(experimentaldecorators=false,target=es2015).js +++ b/tsc/testdata/baselines/reference/compiler/malformedDestructuringAssignmentTransformVariants(experimentaldecorators=false,target=es2015).js @@ -89,7 +89,7 @@ let C = (() => { __setFunctionName(_classThis, "C"); (() => { var _a; - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper === null || _classSuper === void 0 ? void 0 : _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/compiler/malformedDestructuringAssignmentTransformVariants(experimentaldecorators=false,target=es2022).js b/tsc/testdata/baselines/reference/compiler/malformedDestructuringAssignmentTransformVariants(experimentaldecorators=false,target=es2022).js index 3fa29f899dfaa..4d9f410845fa7 100644 --- a/tsc/testdata/baselines/reference/compiler/malformedDestructuringAssignmentTransformVariants(experimentaldecorators=false,target=es2022).js +++ b/tsc/testdata/baselines/reference/compiler/malformedDestructuringAssignmentTransformVariants(experimentaldecorators=false,target=es2022).js @@ -89,7 +89,7 @@ let C = (() => { static { _classThis = this; } static { __setFunctionName(this, "C"); } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/compiler/malformedSuperDestructuringInDecoratedClassStaticBlock.js b/tsc/testdata/baselines/reference/compiler/malformedSuperDestructuringInDecoratedClassStaticBlock.js index f5ec3c111a55b..91a8f3f937288 100644 --- a/tsc/testdata/baselines/reference/compiler/malformedSuperDestructuringInDecoratedClassStaticBlock.js +++ b/tsc/testdata/baselines/reference/compiler/malformedSuperDestructuringInDecoratedClassStaticBlock.js @@ -55,7 +55,7 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p static { _classThis = this; } static { __setFunctionName(_classThis, ""); } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.1.js b/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.1.js index 2a6af1561b585..0ee626e6b19e4 100644 --- a/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.1.js +++ b/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.1.js @@ -35,7 +35,7 @@ let C = (() => { var C = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.2.js b/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.2.js index 843d63870e434..ddf3121265ecd 100644 --- a/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.2.js +++ b/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.2.js @@ -41,7 +41,7 @@ let C1 = (() => { var C1 = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C1 = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); @@ -65,7 +65,7 @@ let C2 = (() => { var C2 = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C2 = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); @@ -89,7 +89,7 @@ let C3 = (() => { var C3 = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C3 = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.3.js b/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.3.js index 895fb121dbfc5..90aad401440af 100644 --- a/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.3.js +++ b/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.3.js @@ -57,7 +57,7 @@ let C = (() => { var C = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.4.js b/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.4.js index 54c4216e41898..ea36afe609a83 100644 --- a/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.4.js +++ b/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.4.js @@ -32,7 +32,7 @@ let C = (() => { var C = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.5.js b/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.5.js index a022bbea15852..d75a4f278bb2a 100644 --- a/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.5.js +++ b/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.5.js @@ -61,7 +61,7 @@ let C1 = (() => { var C1 = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C1 = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); @@ -108,7 +108,7 @@ let C2 = (() => { var C2 = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C2 = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); @@ -155,7 +155,7 @@ let C3 = (() => { var C3 = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C3 = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.6.js b/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.6.js index 24a23c35123d3..a864fbaa2d696 100644 --- a/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.6.js +++ b/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.6.js @@ -39,7 +39,7 @@ let C = (() => { var C = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.7.js b/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.7.js index f1f7df3b0e1b4..c063768af3662 100644 --- a/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.7.js +++ b/tsc/testdata/baselines/reference/conformance/esDecorators-classDeclaration-classSuper.7.js @@ -52,7 +52,7 @@ let B = (() => { let _m_decorators; return class B extends _classSuper { static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; _m_decorators = [foo]; __esDecorate(this, null, _m_decorators, { kind: "method", name: "m", static: false, private: false, access: { has: obj => "m" in obj, get: obj => obj.m }, metadata: _metadata }, null, _instanceExtraInitializers); if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); @@ -97,7 +97,7 @@ let D = (() => { let _get_val_decorators; return class D extends _classSuper { static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; _get_val_decorators = [foo]; __esDecorate(this, null, _get_val_decorators, { kind: "getter", name: "val", static: false, private: false, access: { has: obj => "val" in obj, get: obj => obj.val }, metadata: _metadata }, null, _instanceExtraInitializers); if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.1.js b/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.1.js index dc887e44daa79..0a4aa404e51c6 100644 --- a/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.1.js +++ b/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.1.js @@ -34,7 +34,7 @@ const method = "method"; var C = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.2.js b/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.2.js index 00288d2b678f8..e5d038d25b8f8 100644 --- a/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.2.js +++ b/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.2.js @@ -41,7 +41,7 @@ class C3 extends ((() => {}) as any) { var C1 = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C1 = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); @@ -65,7 +65,7 @@ class C3 extends ((() => {}) as any) { var C2 = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C2 = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); @@ -89,7 +89,7 @@ class C3 extends ((() => {}) as any) { var C3 = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C3 = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.3.js b/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.3.js index 70f73e55c83d3..b9784cd9f99e2 100644 --- a/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.3.js +++ b/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.3.js @@ -57,7 +57,7 @@ const x = "x"; var C = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.4.js b/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.4.js index 0fc63fedf4938..2f9fb08a91b92 100644 --- a/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.4.js +++ b/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.4.js @@ -32,7 +32,7 @@ const method = "method"; var C = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.5.js b/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.5.js index e8a82da1bcdf9..d92a94ca7782b 100644 --- a/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.5.js +++ b/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.5.js @@ -61,7 +61,7 @@ const x = "x"; var C1 = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C1 = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); @@ -108,7 +108,7 @@ const x = "x"; var C2 = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C2 = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); @@ -155,7 +155,7 @@ const x = "x"; var C3 = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C3 = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.6.js b/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.6.js index 5e881f1d7be78..eca6c8a89e521 100644 --- a/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.6.js +++ b/tsc/testdata/baselines/reference/conformance/esDecorators-classExpression-classSuper.6.js @@ -39,7 +39,7 @@ class C extends Base { var C = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata2(target=es2015).js b/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata2(target=es2015).js index 7cba1db397a63..cd78a3fa9dc62 100644 --- a/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata2(target=es2015).js +++ b/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata2(target=es2015).js @@ -111,7 +111,7 @@ let D = (() => { }, (() => { var _b; - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper === null || _classSuper === void 0 ? void 0 : _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0; _m_decorators = [meta('b', 'z')]; __esDecorate(_a, null, _m_decorators, { kind: "method", name: "m", static: false, private: false, access: { has: obj => "m" in obj, get: obj => obj.m }, metadata: _metadata }, null, _instanceExtraInitializers); if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata2(target=es2022).js b/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata2(target=es2022).js index 669c5fed386c6..68e27fc1786da 100644 --- a/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata2(target=es2022).js +++ b/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata2(target=es2022).js @@ -99,7 +99,7 @@ let D = (() => { let _m_decorators; return class D extends _classSuper { static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; _m_decorators = [meta('b', 'z')]; __esDecorate(this, null, _m_decorators, { kind: "method", name: "m", static: false, private: false, access: { has: obj => "m" in obj, get: obj => obj.m }, metadata: _metadata }, null, _instanceExtraInitializers); if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata3(target=es2015).js b/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata3(target=es2015).js index 220847f12023e..0439d638e23a3 100644 --- a/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata3(target=es2015).js +++ b/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata3(target=es2015).js @@ -95,7 +95,7 @@ let D = (() => { __setFunctionName(_classThis, "D"); (() => { var _a; - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper === null || _classSuper === void 0 ? void 0 : _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); D = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata3(target=es2022).js b/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata3(target=es2022).js index b4d39bd35594d..a699e6f06e0ee 100644 --- a/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata3(target=es2022).js +++ b/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata3(target=es2022).js @@ -88,7 +88,7 @@ let D = (() => { var D = class extends _classSuper { static { _classThis = this; } static { - const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); D = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); diff --git a/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata6(target=es2015).js b/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata6(target=es2015).js new file mode 100644 index 0000000000000..c8707d7bd9cde --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata6(target=es2015).js @@ -0,0 +1,113 @@ +//// [tests/cases/conformance/esDecorators/metadata/esDecoratorsMetadata6.ts] //// + +//// [foo.ts] +// The parent metadata object of a class whose superclass is `null` is `null`. +// Reading `Symbol.metadata` from the superclass must not throw. + +function meta(key: string, value: string) { + return (_, context) => { + context.metadata[key] = value; + }; +} + +@meta('a', 'x') +class C extends null { +} + +declare const maybeBase: (new () => object) | null; + +@meta('b', 'y') +class D extends maybeBase { +} + +C[Symbol.metadata].a; // 'x' +D[Symbol.metadata].b; // 'y' + + +//// [foo.js] +"use strict"; +// The parent metadata object of a class whose superclass is `null` is `null`. +// Reading `Symbol.metadata` from the superclass must not throw. +var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { + function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } + var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; + var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; + var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); + var _, done = false; + for (var i = decorators.length - 1; i >= 0; i--) { + var context = {}; + for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; + for (var p in contextIn.access) context.access[p] = contextIn.access[p]; + context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; + var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); + if (kind === "accessor") { + if (result === void 0) continue; + if (result === null || typeof result !== "object") throw new TypeError("Object expected"); + if (_ = accept(result.get)) descriptor.get = _; + if (_ = accept(result.set)) descriptor.set = _; + if (_ = accept(result.init)) initializers.unshift(_); + } + else if (_ = accept(result)) { + if (kind === "field") initializers.unshift(_); + else descriptor[key] = _; + } + } + if (target) Object.defineProperty(target, contextIn.name, descriptor); + done = true; +}; +var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) { + var useValue = arguments.length > 2; + for (var i = 0; i < initializers.length; i++) { + value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); + } + return useValue ? value : void 0; +}; +var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) { + if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; + return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); +}; +function meta(key, value) { + return (_, context) => { + context.metadata[key] = value; + }; +} +let C = (() => { + let _classDecorators = [meta('a', 'x')]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _classSuper = null; + var C = _classThis = class extends _classSuper { + }; + __setFunctionName(_classThis, "C"); + (() => { + var _a; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper === null || _classSuper === void 0 ? void 0 : _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0; + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +})(); +let D = (() => { + let _classDecorators = [meta('b', 'y')]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _classSuper = maybeBase; + var D = _classThis = class extends _classSuper { + }; + __setFunctionName(_classThis, "D"); + (() => { + var _a; + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper === null || _classSuper === void 0 ? void 0 : _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0; + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); + D = _classThis = _classDescriptor.value; + if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); + __runInitializers(_classThis, _classExtraInitializers); + })(); + return D = _classThis; +})(); +C[Symbol.metadata].a; // 'x' +D[Symbol.metadata].b; // 'y' diff --git a/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata6(target=es2022).js b/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata6(target=es2022).js new file mode 100644 index 0000000000000..fd72303eb8cc7 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/esDecoratorsMetadata6(target=es2022).js @@ -0,0 +1,107 @@ +//// [tests/cases/conformance/esDecorators/metadata/esDecoratorsMetadata6.ts] //// + +//// [foo.ts] +// The parent metadata object of a class whose superclass is `null` is `null`. +// Reading `Symbol.metadata` from the superclass must not throw. + +function meta(key: string, value: string) { + return (_, context) => { + context.metadata[key] = value; + }; +} + +@meta('a', 'x') +class C extends null { +} + +declare const maybeBase: (new () => object) | null; + +@meta('b', 'y') +class D extends maybeBase { +} + +C[Symbol.metadata].a; // 'x' +D[Symbol.metadata].b; // 'y' + + +//// [foo.js] +"use strict"; +// The parent metadata object of a class whose superclass is `null` is `null`. +// Reading `Symbol.metadata` from the superclass must not throw. +var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { + function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } + var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; + var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; + var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); + var _, done = false; + for (var i = decorators.length - 1; i >= 0; i--) { + var context = {}; + for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; + for (var p in contextIn.access) context.access[p] = contextIn.access[p]; + context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; + var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); + if (kind === "accessor") { + if (result === void 0) continue; + if (result === null || typeof result !== "object") throw new TypeError("Object expected"); + if (_ = accept(result.get)) descriptor.get = _; + if (_ = accept(result.set)) descriptor.set = _; + if (_ = accept(result.init)) initializers.unshift(_); + } + else if (_ = accept(result)) { + if (kind === "field") initializers.unshift(_); + else descriptor[key] = _; + } + } + if (target) Object.defineProperty(target, contextIn.name, descriptor); + done = true; +}; +var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) { + var useValue = arguments.length > 2; + for (var i = 0; i < initializers.length; i++) { + value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); + } + return useValue ? value : void 0; +}; +function meta(key, value) { + return (_, context) => { + context.metadata[key] = value; + }; +} +let C = (() => { + let _classDecorators = [meta('a', 'x')]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _classSuper = null; + var C = class extends _classSuper { + static { _classThis = this; } + static { + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); + __runInitializers(_classThis, _classExtraInitializers); + } + }; + return C = _classThis; +})(); +let D = (() => { + let _classDecorators = [meta('b', 'y')]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _classSuper = maybeBase; + var D = class extends _classSuper { + static { _classThis = this; } + static { + const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper?.[Symbol.metadata] ?? null) : void 0; + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); + D = _classThis = _classDescriptor.value; + if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); + __runInitializers(_classThis, _classExtraInitializers); + } + }; + return D = _classThis; +})(); +C[Symbol.metadata].a; // 'x' +D[Symbol.metadata].b; // 'y' diff --git a/tsc/testdata/tests/cases/conformance/esDecorators/metadata/esDecoratorsMetadata6.ts b/tsc/testdata/tests/cases/conformance/esDecorators/metadata/esDecoratorsMetadata6.ts new file mode 100644 index 0000000000000..b39547a82f579 --- /dev/null +++ b/tsc/testdata/tests/cases/conformance/esDecorators/metadata/esDecoratorsMetadata6.ts @@ -0,0 +1,27 @@ +// @strict: false +// @target: es2022,es2015 +// @noTypesAndSymbols: true +// @lib: esnext +// @filename: /foo.ts + +// The parent metadata object of a class whose superclass is `null` is `null`. +// Reading `Symbol.metadata` from the superclass must not throw. + +function meta(key: string, value: string) { + return (_, context) => { + context.metadata[key] = value; + }; +} + +@meta('a', 'x') +class C extends null { +} + +declare const maybeBase: (new () => object) | null; + +@meta('b', 'y') +class D extends maybeBase { +} + +C[Symbol.metadata].a; // 'x' +D[Symbol.metadata].b; // 'y'