Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tsc/internal/transformers/estransforms/esdecorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2198,7 +2198,6 @@ func (tx *esDecoratorTransformer) visitAssignmentRestElement(node *ast.Node) *as
}

func (tx *esDecoratorTransformer) visitArrayAssignmentElement(node *ast.Node) *ast.Node {
debug.Assert(ast.IsArrayBindingOrAssignmentElement(node))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same reasoning as #63972 (comment)

if ast.IsSpreadElement(node) {
return tx.visitAssignmentRestElement(node)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
malformedSuperDestructuringInDecoratedClassStaticBlock.ts(1,3): error TS2304: Cannot find name 'c'.
malformedSuperDestructuringInDecoratedClassStaticBlock.ts(2,15): error TS2304: Cannot find name 'B'.
malformedSuperDestructuringInDecoratedClassStaticBlock.ts(2,33): error TS1005: ',' expected.
malformedSuperDestructuringInDecoratedClassStaticBlock.ts(2,33): error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
malformedSuperDestructuringInDecoratedClassStaticBlock.ts(2,33): error TS2493: Tuple type '[number]' of length '1' has no element at index '1'.


==== malformedSuperDestructuringInDecoratedClassStaticBlock.ts (5 errors) ====
(@c
~
!!! error TS2304: Cannot find name 'c'.
class extends B{static{[super.x 0]=[1];}});
~
!!! error TS2304: Cannot find name 'B'.
~
!!! error TS1005: ',' expected.
~
!!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access.
~
!!! error TS2493: Tuple type '[number]' of length '1' has no element at index '1'.

Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//// [tests/cases/compiler/malformedSuperDestructuringInDecoratedClassStaticBlock.ts] ////

//// [malformedSuperDestructuringInDecoratedClassStaticBlock.ts]
(@c
class extends B{static{[super.x 0]=[1];}});


//// [malformedSuperDestructuringInDecoratedClassStaticBlock.js]
"use strict";
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 });
};
((() => {
let _classDecorators = [c];
let _classDescriptor;
let _classExtraInitializers = [];
let _classThis;
let _classSuper = B;
var class_1 = class extends _classSuper {
static { _classThis = this; }
static { __setFunctionName(_classThis, ""); }
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);
class_1 = _classThis = _classDescriptor.value;
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
}
static { [({ set value(_a) { Reflect.set(_classSuper, "x", _a, _classThis); } }).value, 0] = [1]; }
static {
__runInitializers(_classThis, _classExtraInitializers);
}
};
return class_1 = _classThis;
})());
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//// [tests/cases/compiler/malformedSuperDestructuringInDecoratedClassStaticBlock.ts] ////

=== malformedSuperDestructuringInDecoratedClassStaticBlock.ts ===

(@c
class extends B{static{[super.x 0]=[1];}});

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//// [tests/cases/compiler/malformedSuperDestructuringInDecoratedClassStaticBlock.ts] ////

=== malformedSuperDestructuringInDecoratedClassStaticBlock.ts ===
(@c
>(@cclass extends B{static{[super.x 0]=[1];}}) : typeof (Anonymous class)
>@cclass extends B{static{[super.x 0]=[1];}} : typeof (Anonymous class)
>c : any

class extends B{static{[super.x 0]=[1];}});
>B : any
>[super.x 0]=[1] : [number]
>[super.x 0] : [any, number]
>super.x : any
>super : any
>x : any
>0 : 0
>[1] : [number]
>1 : 1

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @target: es2022

(@c
class extends B{static{[super.x 0]=[1];}});
Loading