[Decorators] Missing error when calling `addInitializer` after that the decorator is done

Đang mở
#57,300 3 bình luận 0 reaction 1 người được giao Xem trên GitHub

@rbuckton đang làm issue này rồi.

Từ ngày 5/2/2024.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

Needs Investigation
🔎 Search Terms

decorators addInitializer error

🕗 Version & Regression Information
  • This is the behavior in every version I tried since Stage 3 decorators where implemented
⏯ Playground Link

https://www.typescriptlang.org/play?#code/DYUwLgBAhgJjCSA7AlmZVjIF4gE4DFcB7AWwEYAuCAERAGMjcoxGBhIxMEADzAG0ARLAQo0GbHgEBdANwBYAFCKAZgFdEdNBwgx6ZABQB9KlEQBPADQRN3KrQZMWudpx5gAlBADeiiNDhIqOiYOATE5BAAvNZg3AB0woFiIXjyCgC+iirqmsjaunQATEYm5laGhaVmnj4KfomiwRJhpAb6npEAfN7p7r7WHADORKBxwEQA5voCAILU1ACi1AJ9GVkKdMBQg4MQM979AAIFhUcFZP3KRERREGRpmUoKQA

💻 Code
let addInitializerFrom1: DecoratorContext["addInitializer"];

function dec1(_: any, ctx: DecoratorContext) {
  addInitializerFrom1 = ctx.addInitializer;
}

function dec2(_: any, _2: any) {
  addInitializerFrom1(() => {})
  console.log("ADDED")
}

class A {
  @dec2
  @dec1
  foo = 1;
}
🙁 Actual behavior

The addInitializerFrom1 call should throw

🙂 Expected behavior

addInitializerFrom1 doesn't throw

Additional information about the issue

Spec: https://ci.tc39.es/preview/tc39/ecma262/sha/59003ed603d09485b957a0f579b46697f49a96a6/#sec-applydecoratorstoelementdefinition

After that dec1 is called, decorationState.[[Finished]] for the decorationState relative to dec1 is set to false and thus calling addInitializer should throw.

Ngôn ngữ chính
Go
Star
111k
Fork
14.4k
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
117

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/TypeScript

Tất cả issue của microsoft/TypeScript

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.