Side effect of decorator
@rbuckton がすでに取り組んでいます。
2023年10月5日 から。
評価
この issue はまだ評価されていません。
説明
🔎 Search Terms
"decorator" "field decorator" "side effect" "decorator side effect"
🕗 Version & Regression Information
- This changed between versions 5.0 and 5.2
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about decorators
⏯ Playground Link
💻 Code
const FieldDecorator = (target: undefined, context: ClassFieldDecoratorContext) => {} // do nothing
class Parent {
constructor(arg1: string, arg2: string, arg3: string) {
// @ts-ignore
this.prop1 = arg1
// @ts-ignore
this.prop2 = arg2
// @ts-ignore
this.prop3 = arg3
}
}
class Child extends Parent {
prop1!: string
prop2!: string
@FieldDecorator
prop3!: string
}
const a = new Child('11', '22', '33')
console.log(a)
// a.prop1 === undefined // WTF
// a.prop2 === '22' // OK
// a.prop3 === undefined // WTF
🙁 Actual behavior
the decorated property and the very first property are undefined despite the fact that they are given a value in the constructor
🙂 Expected behavior
a object should be equal to the following obj object
const obj = {
prop1: "11"
prop2: "22"
prop3: "33"
}
Additional information about the issue
No response
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/TypeScript のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
microsoft/TypeScript#64322 · コメント 2 件 · リアクション 1 件 · 担当者 2 名 ·
-
Possible Improvement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/TypeScript#64278 · コメント 1 件 · リアクション 1 件 ·
-
Docs
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
microsoft/TypeScript#64118 · コメント 1 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
microsoft/TypeScript#64094 ·
-
Docs
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
microsoft/TypeScript#63959 · コメント 5 件 ·
microsoft/TypeScript の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
milvus-io/birdwatcher#545 ·
-
kind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
kubernetes-sigs/prow#953 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
caddyserver/caddy#8046 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
jaegertracing/jaeger#9588 ·