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

オープン
#57,300 コメント 3 件 リアクション 0 件 担当者 1 名 GitHub で見る

@rbuckton がすでに取り組んでいます。

2024年2月5日 から。

評価

この issue はまだ評価されていません。

説明

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.

主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 15時間
マージ済み PR(30日)
106

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/TypeScript のほかの issue

microsoft/TypeScript の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。